m7mdal7aj commited on
Commit
7236022
1 Parent(s): d80fd56

Update my_model/tabs/run_inference.py

Browse files
Files changed (1) hide show
  1. my_model/tabs/run_inference.py +16 -8
my_model/tabs/run_inference.py CHANGED
@@ -96,21 +96,29 @@ def process_new_image(image_key, image, kbvqa):
96
  def run_inference():
97
  st.title("Run Inference")
98
 
99
- method = st.selectbox("Choose a method:", ["Fine-Tuned Model", "In-Context Learning (n-shots)"], index=0)
100
- detection_model = st.selectbox("Choose a model for objects detection:", ["yolov5", "detic"], index=1)
101
  default_confidence = 0.2 if detection_model == "yolov5" else 0.4
102
- confidence_level = st.slider("Select minimum detection confidence level", min_value=0.1, max_value=0.9, value=default_confidence, step=0.1)
 
 
 
 
 
 
 
103
 
104
- state_manager.update_model_settings(detection_model=detection_model, confidence_level=confidence_level, selected_method=method)
105
 
106
 
107
- need_model_reload = state_manager.check_settings_changed(method, detection_model, confidence_level) and state_manager.is_model_loaded()
108
- button_label = "Reload Model" if need_model_reload else "Load Model"
 
109
 
110
  if method == "Fine-Tuned Model":
111
  if st.button(button_label):
112
- if not need_model_reload:
113
- st write(st.session_state['kbvqa'])
114
  st.write("Model already loaded.")
115
  else:
116
  st.text("Loading the model, please wait...")
 
96
  def run_inference():
97
  st.title("Run Inference")
98
 
99
+ st.selectbox("Choose a method:", ["Fine-Tuned Model", "In-Context Learning (n-shots)"], index=0, key='method')
100
+ st.selectbox("Choose a model for objects detection:", ["yolov5", "detic"], index=1, key='detection_model')
101
  default_confidence = 0.2 if detection_model == "yolov5" else 0.4
102
+ # confidence_level = st.slider("Select minimum detection confidence level", min_value=0.1, max_value=0.9, value=default_confidence, step=0.1)
103
+ state_manager.set_slider_value(text="Select minimum detection confidence level",
104
+ min_value=0.1,
105
+ max_value=0.9,
106
+ value=default_confidence,
107
+ step=0.1,
108
+ slider_key_name='confidence_level',
109
+ )
110
 
111
+ # state_manager.update_model_settings(detection_model=detection_model, confidence_level=confidence_level, selected_method=method)
112
 
113
 
114
+ # need_model_reload = state_manager.check_settings_changed(method, detection_model, confidence_level) and state_manager.is_model_loaded()
115
+ need_model_reload =
116
+ button_label = "Reload Model" if st.session_state['kbvqa'] else "Load Model"
117
 
118
  if method == "Fine-Tuned Model":
119
  if st.button(button_label):
120
+ if button_label == "Load Model" and :
121
+ # st write(st.session_state['kbvqa'])
122
  st.write("Model already loaded.")
123
  else:
124
  st.text("Loading the model, please wait...")