Update my_model/state_manager.py
Browse files
my_model/state_manager.py
CHANGED
@@ -162,6 +162,7 @@ class StateManager:
|
|
162 |
st.session_state['model_loaded'] = True
|
163 |
st.session_state['button_label'] = "Reload Model"
|
164 |
free_gpu_resources()
|
|
|
165 |
|
166 |
except Exception as e:
|
167 |
st.error(f"Error loading model: {e}")
|
@@ -202,7 +203,9 @@ class StateManager:
|
|
202 |
try:
|
203 |
del st.session_state['kbvqa']
|
204 |
free_gpu_resources()
|
|
|
205 |
except:
|
|
|
206 |
free_gpu_resources()
|
207 |
pass
|
208 |
|
@@ -314,6 +317,9 @@ class StateManager:
|
|
314 |
Returns:
|
315 |
tuple: A tuple containing the generated caption, detected objects string, and image with bounding boxes.
|
316 |
"""
|
|
|
|
|
|
|
317 |
img = copy.deepcopy(image)
|
318 |
caption = st.session_state['kbvqa'].get_caption(img)
|
319 |
image_with_boxes, detected_objects_str = st.session_state['kbvqa'].detect_objects(img)
|
|
|
162 |
st.session_state['model_loaded'] = True
|
163 |
st.session_state['button_label'] = "Reload Model"
|
164 |
free_gpu_resources()
|
165 |
+
free_gpu_resources()
|
166 |
|
167 |
except Exception as e:
|
168 |
st.error(f"Error loading model: {e}")
|
|
|
203 |
try:
|
204 |
del st.session_state['kbvqa']
|
205 |
free_gpu_resources()
|
206 |
+
free_gpu_resources()
|
207 |
except:
|
208 |
+
free_gpu_resources()
|
209 |
free_gpu_resources()
|
210 |
pass
|
211 |
|
|
|
317 |
Returns:
|
318 |
tuple: A tuple containing the generated caption, detected objects string, and image with bounding boxes.
|
319 |
"""
|
320 |
+
|
321 |
+
free_gpu_resources()
|
322 |
+
free_gpu_resources()
|
323 |
img = copy.deepcopy(image)
|
324 |
caption = st.session_state['kbvqa'].get_caption(img)
|
325 |
image_with_boxes, detected_objects_str = st.session_state['kbvqa'].detect_objects(img)
|