cmckinle commited on
Commit
0b59685
·
verified ·
1 Parent(s): b19163e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -7
app.py CHANGED
@@ -51,7 +51,6 @@ def process_zip(zip_file):
51
  if not ('real/' in file_list and 'ai/' in file_list):
52
  raise ValueError("Zip file must contain 'real' and 'ai' folders")
53
 
54
- yield "Extracting files...", gr.Progress(0)
55
  z.extractall(temp_dir)
56
 
57
  labels, preds, images = [], [], []
@@ -61,8 +60,6 @@ def process_zip(zip_file):
61
  total_images = sum(len(files) for _, _, files in os.walk(temp_dir))
62
  processed_images = 0
63
 
64
- yield f"Processing {total_images} images...", gr.Progress(0)
65
-
66
  for folder_name, ground_truth_label in [('real', 1), ('ai', 0)]:
67
  folder_path = os.path.join(temp_dir, folder_name)
68
  if not os.path.exists(folder_path):
@@ -93,9 +90,8 @@ def process_zip(zip_file):
93
  print(f"Error processing image {img_name}: {e}")
94
 
95
  processed_images += 1
96
- yield f"Processing image {processed_images} of {total_images}...", gr.Progress(processed_images / total_images)
97
 
98
- yield "Evaluating model...", gr.Progress(1)
99
  return evaluate_model(labels, preds, false_positives, false_negatives)
100
 
101
  except Exception as e:
@@ -320,7 +316,6 @@ def create_gradio_interface():
320
  max_file_size=1024 # 1024 MB (1 GB)
321
  )
322
  batch_btn = gr.Button("Process Batch", interactive=False)
323
- progress_output = gr.Textbox(label="Progress")
324
 
325
  with gr.Group():
326
  gr.Markdown(f"### Results for {MODEL_NAME}")
@@ -349,7 +344,7 @@ def create_gradio_interface():
349
  batch_btn.click(
350
  process_zip,
351
  zip_file,
352
- [progress_output, progress_output, output_acc, output_roc, output_report, output_plots, output_fp_fn],
353
  api_name="batch_process"
354
  )
355
 
 
51
  if not ('real/' in file_list and 'ai/' in file_list):
52
  raise ValueError("Zip file must contain 'real' and 'ai' folders")
53
 
 
54
  z.extractall(temp_dir)
55
 
56
  labels, preds, images = [], [], []
 
60
  total_images = sum(len(files) for _, _, files in os.walk(temp_dir))
61
  processed_images = 0
62
 
 
 
63
  for folder_name, ground_truth_label in [('real', 1), ('ai', 0)]:
64
  folder_path = os.path.join(temp_dir, folder_name)
65
  if not os.path.exists(folder_path):
 
90
  print(f"Error processing image {img_name}: {e}")
91
 
92
  processed_images += 1
93
+ gr.Progress(processed_images / total_images)
94
 
 
95
  return evaluate_model(labels, preds, false_positives, false_negatives)
96
 
97
  except Exception as e:
 
316
  max_file_size=1024 # 1024 MB (1 GB)
317
  )
318
  batch_btn = gr.Button("Process Batch", interactive=False)
 
319
 
320
  with gr.Group():
321
  gr.Markdown(f"### Results for {MODEL_NAME}")
 
344
  batch_btn.click(
345
  process_zip,
346
  zip_file,
347
+ [output_acc, output_roc, output_report, output_plots, output_fp_fn],
348
  api_name="batch_process"
349
  )
350