Spaces:
Sleeping
Sleeping
Update my_model/state_manager.py
Browse files- my_model/state_manager.py +3 -14
my_model/state_manager.py
CHANGED
@@ -137,7 +137,7 @@ class StateManager:
|
|
137 |
st.session_state['kbvqa'] = prepare_kbvqa_model()
|
138 |
st.session_state['kbvqa'].detection_confidence = st.session_state.confidence_level
|
139 |
# Update the previous state with current session state values
|
140 |
-
st.session_state['previous_state'] = {'method': st.session_state.method, 'detection_model': st.session_state.detection_model
|
141 |
st.session_state['model_loaded'] = True
|
142 |
st.session_state['button_label'] = "Reload Model"
|
143 |
free_gpu_resources()
|
@@ -225,22 +225,11 @@ class StateManager:
|
|
225 |
|
226 |
st.write(st.session_state['detection_model'] == st.session_state['previous_state']['detection_model'])
|
227 |
st.write(st.session_state['method'] == st.session_state['previous_state']['method'])
|
228 |
-
st.write(st.session_state['confidence_level'] != st.session_state['previous_state']['confidence_level'])
|
229 |
-
|
230 |
-
# check if only confidence is changed
|
231 |
-
if st.session_state['detection_model'] == st.session_state['previous_state']['detection_model']\
|
232 |
-
and st.session_state['method'] == st.session_state['previous_state']['method'] \
|
233 |
-
and st.session_state['confidence_level'] != st.session_state['previous_state']['confidence_level']:
|
234 |
-
|
235 |
-
st.session_state['kbvqa'].detection_confidence = st.session_state.confidence_level
|
236 |
-
st.write("reload func", st.session_state['kbvqa'].detection_confidence )
|
237 |
-
st.session_state['confidence_level_changed'] = True
|
238 |
-
return # only update the confidence level
|
239 |
|
240 |
prepare_kbvqa_model(only_reload_detection_model=True)
|
241 |
st.session_state['kbvqa'].detection_confidence = st.session_state.confidence_level
|
242 |
self.col1.success("Model reloaded with updated settings and ready for inference.")
|
243 |
-
st.session_state['previous_state'] = {'method': st.session_state.method, 'detection_model': st.session_state.detection_model
|
244 |
st.session_state['button_label'] = "Reload Model"
|
245 |
|
246 |
free_gpu_resources()
|
@@ -292,7 +281,7 @@ class StateManager:
|
|
292 |
tuple: A tuple containing the generated caption, detected objects string, and image with bounding boxes.
|
293 |
"""
|
294 |
img = copy.deepcopy(image)
|
295 |
-
st.text("Analyzing the image .. ")
|
296 |
caption = st.session_state['kbvqa'].get_caption(img)
|
297 |
image_with_boxes, detected_objects_str = st.session_state['kbvqa'].detect_objects(img)
|
298 |
|
|
|
137 |
st.session_state['kbvqa'] = prepare_kbvqa_model()
|
138 |
st.session_state['kbvqa'].detection_confidence = st.session_state.confidence_level
|
139 |
# Update the previous state with current session state values
|
140 |
+
st.session_state['previous_state'] = {'method': st.session_state.method, 'detection_model': st.session_state.detection_model}
|
141 |
st.session_state['model_loaded'] = True
|
142 |
st.session_state['button_label'] = "Reload Model"
|
143 |
free_gpu_resources()
|
|
|
225 |
|
226 |
st.write(st.session_state['detection_model'] == st.session_state['previous_state']['detection_model'])
|
227 |
st.write(st.session_state['method'] == st.session_state['previous_state']['method'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
prepare_kbvqa_model(only_reload_detection_model=True)
|
230 |
st.session_state['kbvqa'].detection_confidence = st.session_state.confidence_level
|
231 |
self.col1.success("Model reloaded with updated settings and ready for inference.")
|
232 |
+
st.session_state['previous_state'] = {'method': st.session_state.method, 'detection_model': st.session_state.detection_model}
|
233 |
st.session_state['button_label'] = "Reload Model"
|
234 |
|
235 |
free_gpu_resources()
|
|
|
281 |
tuple: A tuple containing the generated caption, detected objects string, and image with bounding boxes.
|
282 |
"""
|
283 |
img = copy.deepcopy(image)
|
284 |
+
st.text("Analyzing the image .. please wait")
|
285 |
caption = st.session_state['kbvqa'].get_caption(img)
|
286 |
image_with_boxes, detected_objects_str = st.session_state['kbvqa'].detect_objects(img)
|
287 |
|