Alessio Grancini commited on
Commit
8db3d77
·
verified ·
1 Parent(s): 4642da2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -5
app.py CHANGED
@@ -102,8 +102,17 @@ def update_segmentation_options(options):
102
  #def update_confidence_threshold(thres_val):
103
  # img_seg.confidence_threshold = thres_val/100
104
 
 
 
 
 
 
 
105
  def update_confidence_threshold(thres_val, img_seg_instance):
106
  """Update confidence threshold in ImageSegmenter"""
 
 
 
107
  img_seg_instance.confidence_threshold = thres_val
108
  print(f"Confidence threshold updated to: {thres_val}")
109
 
@@ -473,16 +482,29 @@ if __name__ == "__main__":
473
 
474
 
475
  # image tab logic
 
 
 
 
 
 
 
 
 
 
 
 
 
476
  submit_btn_img.click(process_image, inputs=img_input, outputs=[segmentation_img_output, depth_img_output, dist_img_output, pcd_img_output])
477
  options_checkbox_img.change(update_segmentation_options, options_checkbox_img, [])
478
- conf_thres_img.change(update_confidence_threshold, conf_thres_img, [])
479
- model_type_img.change(model_selector, model_type_img, [])
480
 
481
- # video tab logic
482
  submit_btn_vid.click(process_video, inputs=vid_input, outputs=[segmentation_vid_output, depth_vid_output, dist_vid_output])
483
- model_type_vid.change(model_selector, model_type_vid, [])
484
  cancel_btn.click(cancel, inputs=[], outputs=[])
485
  options_checkbox_vid.change(update_segmentation_options, options_checkbox_vid, [])
486
- conf_thres_vid.change(update_confidence_threshold, conf_thres_vid, [])
487
 
488
  my_app.queue(max_size=20).launch(share=True) # Add share=True here
 
102
  #def update_confidence_threshold(thres_val):
103
  # img_seg.confidence_threshold = thres_val/100
104
 
105
+ #def update_confidence_threshold(thres_val, img_seg_instance):
106
+ # """Update confidence threshold in ImageSegmenter"""
107
+ # img_seg_instance.confidence_threshold = thres_val
108
+ # print(f"Confidence threshold updated to: {thres_val}")
109
+
110
+
111
  def update_confidence_threshold(thres_val, img_seg_instance):
112
  """Update confidence threshold in ImageSegmenter"""
113
+ # For Gradio UI (0-100), convert to 0.0-1.0; for API (0.0-1.0), use directly
114
+ if thres_val > 1.0: # Assume Gradio slider value
115
+ thres_val = thres_val / 100.0
116
  img_seg_instance.confidence_threshold = thres_val
117
  print(f"Confidence threshold updated to: {thres_val}")
118
 
 
482
 
483
 
484
  # image tab logic
485
+ #submit_btn_img.click(process_image, inputs=img_input, outputs=[segmentation_img_output, depth_img_output, dist_img_output, pcd_img_output])
486
+ #options_checkbox_img.change(update_segmentation_options, options_checkbox_img, [])
487
+ #conf_thres_img.change(update_confidence_threshold, conf_thres_img, [])
488
+ #model_type_img.change(model_selector, model_type_img, [])
489
+
490
+ # video tab logic
491
+ #submit_btn_vid.click(process_video, inputs=vid_input, outputs=[segmentation_vid_output, depth_vid_output, dist_vid_output])
492
+ #model_type_vid.change(model_selector, model_type_vid, [])
493
+ #cancel_btn.click(cancel, inputs=[], outputs=[])
494
+ #options_checkbox_vid.change(update_segmentation_options, options_checkbox_vid, [])
495
+ #conf_thres_vid.change(update_confidence_threshold, conf_thres_vid, [])
496
+
497
+ # Image tab logic
498
  submit_btn_img.click(process_image, inputs=img_input, outputs=[segmentation_img_output, depth_img_output, dist_img_output, pcd_img_output])
499
  options_checkbox_img.change(update_segmentation_options, options_checkbox_img, [])
500
+ conf_thres_img.change(lambda x: update_confidence_threshold(x, img_seg), conf_thres_img, []) # Pass img_seg explicitly
501
+ model_type_img.change(lambda x: model_selector(x, img_seg, depth_estimator), model_type_img, [])
502
 
503
+ # Video tab logic
504
  submit_btn_vid.click(process_video, inputs=vid_input, outputs=[segmentation_vid_output, depth_vid_output, dist_vid_output])
505
+ model_type_vid.change(lambda x: model_selector(x, img_seg, depth_estimator), model_type_vid, [])
506
  cancel_btn.click(cancel, inputs=[], outputs=[])
507
  options_checkbox_vid.change(update_segmentation_options, options_checkbox_vid, [])
508
+ conf_thres_vid.change(lambda x: update_confidence_threshold(x, img_seg), conf_thres_vid, []) # Pass img_seg explicitly
509
 
510
  my_app.queue(max_size=20).launch(share=True) # Add share=True here