Spaces:
Running
Running
Update my_model/state_manager.py
Browse files
my_model/state_manager.py
CHANGED
@@ -136,14 +136,10 @@ class StateManager:
|
|
136 |
|
137 |
def force_reload_model(self):
|
138 |
try:
|
139 |
-
st.text("CCCCCC")
|
140 |
self.delete_model()
|
141 |
-
st.text("BBBBB")
|
142 |
self.initialize_state()
|
143 |
-
st.text("DDDD")
|
144 |
free_gpu_resources()
|
145 |
st.session_state['kbvqa'] = prepare_kbvqa_model(force_reload=True)
|
146 |
-
st.text("EEEEE")
|
147 |
st.session_state['kbvqa'].detection_confidence = st.session_state.confidence_level
|
148 |
# Update the previous state with current session state values
|
149 |
st.session_state['previous_state'] = {'method': st.session_state.method, 'detection_model': st.session_state.detection_model, 'confidence_level': st.session_state.confidence_level}
|
@@ -161,11 +157,13 @@ class StateManager:
|
|
161 |
free_gpu_resources()
|
162 |
|
163 |
if self.is_model_loaded():
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
|
|
|
|
169 |
|
170 |
|
171 |
# Function to check if any session state values have changed
|
|
|
136 |
|
137 |
def force_reload_model(self):
|
138 |
try:
|
|
|
139 |
self.delete_model()
|
|
|
140 |
self.initialize_state()
|
|
|
141 |
free_gpu_resources()
|
142 |
st.session_state['kbvqa'] = prepare_kbvqa_model(force_reload=True)
|
|
|
143 |
st.session_state['kbvqa'].detection_confidence = st.session_state.confidence_level
|
144 |
# Update the previous state with current session state values
|
145 |
st.session_state['previous_state'] = {'method': st.session_state.method, 'detection_model': st.session_state.detection_model, 'confidence_level': st.session_state.confidence_level}
|
|
|
157 |
free_gpu_resources()
|
158 |
|
159 |
if self.is_model_loaded():
|
160 |
+
try:
|
161 |
+
del st.session_state['kbvqa']
|
162 |
+
free_gpu_resources()
|
163 |
+
except:
|
164 |
+
free_gpu_resources()
|
165 |
+
pass
|
166 |
+
|
167 |
|
168 |
|
169 |
# Function to check if any session state values have changed
|