dsid271 commited on
Commit
0c26def
·
verified ·
1 Parent(s): 6b66e63

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -20,8 +20,12 @@ def predict_image(image_file, conf_threshold):
20
  print(f"Confidence threshold: {conf_threshold}")
21
 
22
  # Clear previous results if any
23
- for f in os.listdir(output_dir):
24
- os.remove(os.path.join(output_dir, f))
 
 
 
 
25
 
26
  results = model.predict(source=image_file, conf=conf_threshold, save=True, project=output_dir, name="run", exist_ok=True)
27
 
@@ -64,4 +68,4 @@ with gr.Blocks() as demo:
64
  image_button.click(predict_image, inputs=[image_input, image_conf_slider], outputs=image_output)
65
 
66
  # 4. Launch the Gradio interface
67
- demo.launch(share=True)
 
20
  print(f"Confidence threshold: {conf_threshold}")
21
 
22
  # Clear previous results if any
23
+ for item in os.listdir(output_dir):
24
+ item_path = os.path.join(output_dir, item)
25
+ if os.path.isfile(item_path):
26
+ os.remove(item_path)
27
+ elif os.path.isdir(item_path):
28
+ shutil.rmtree(item_path)
29
 
30
  results = model.predict(source=image_file, conf=conf_threshold, save=True, project=output_dir, name="run", exist_ok=True)
31
 
 
68
  image_button.click(predict_image, inputs=[image_input, image_conf_slider], outputs=image_output)
69
 
70
  # 4. Launch the Gradio interface
71
+ demo.launch(share=True)