cmckinle commited on
Commit
2e039a9
·
verified ·
1 Parent(s): 1d7c27a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -1
app.py CHANGED
@@ -364,6 +364,8 @@ def create_gradio_interface():
364
  output_plots = gr.Plot(label="Confusion Matrix and ROC Curve")
365
  output_fp_fn = gr.HTML(label="False Positives and Negatives")
366
 
 
 
367
  load_btn.click(load_url, in_url, [inp, message])
368
  btn.click(
369
  lambda img: detector.predict(img),
@@ -374,4 +376,50 @@ def create_gradio_interface():
374
  def enable_zip_btn(file):
375
  return gr.Button.update(interactive=file is not None)
376
 
377
- def enable_individual_btn
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
364
  output_plots = gr.Plot(label="Confusion Matrix and ROC Curve")
365
  output_fp_fn = gr.HTML(label="False Positives and Negatives")
366
 
367
+ reset_btn = gr.Button("Reset")
368
+
369
  load_btn.click(load_url, in_url, [inp, message])
370
  btn.click(
371
  lambda img: detector.predict(img),
 
376
  def enable_zip_btn(file):
377
  return gr.Button.update(interactive=file is not None)
378
 
379
+ def enable_individual_btn(ai_files, real_files):
380
+ return gr.Button.update(interactive=(ai_files is not None and real_files is not None))
381
+
382
+ zip_file.upload(enable_zip_btn, zip_file, zip_process_btn)
383
+
384
+ ai_files.upload(enable_individual_btn, [ai_files, real_files], individual_process_btn)
385
+ real_files.upload(enable_individual_btn, [ai_files, real_files], individual_process_btn)
386
+
387
+ zip_process_btn.click(
388
+ process_zip,
389
+ zip_file,
390
+ [output_acc, output_roc, output_report, output_plots, output_fp_fn]
391
+ )
392
+
393
+ individual_process_btn.click(
394
+ process_files,
395
+ [ai_files, real_files],
396
+ [output_acc, output_roc, output_report, output_plots, output_fp_fn]
397
+ )
398
+
399
+ def reset_interface():
400
+ return [
401
+ None, None, None, None, None, # Reset inputs
402
+ gr.Button.update(interactive=False), # Reset zip process button
403
+ gr.Button.update(interactive=False), # Reset individual process button
404
+ None, None, None, None, None # Reset outputs
405
+ ]
406
+
407
+ reset_btn.click(
408
+ reset_interface,
409
+ inputs=None,
410
+ outputs=[
411
+ zip_file, ai_files, real_files,
412
+ output_acc, output_roc, output_report, output_plots, output_fp_fn,
413
+ zip_process_btn, individual_process_btn
414
+ ]
415
+ )
416
+
417
+ return app
418
+
419
+ if __name__ == "__main__":
420
+ app = create_gradio_interface()
421
+ app.launch(
422
+ show_api=False,
423
+ max_threads=24,
424
+ show_error=True
425
+ )