m7mdal7aj commited on
Commit
a845f80
1 Parent(s): 6b844f6

Update my_model/state_manager.py

Browse files
Files changed (1) hide show
  1. my_model/state_manager.py +4 -0
my_model/state_manager.py CHANGED
@@ -139,6 +139,7 @@ class StateManager:
139
 
140
  def force_reload_model(self):
141
  try:
 
142
  self.delete_model()
143
  self.initialize_state()
144
  free_gpu_resources()
@@ -147,6 +148,7 @@ class StateManager:
147
  # Update the previous state with current session state values
148
  st.session_state['previous_state'] = {'method': st.session_state.method, 'detection_model': st.session_state.detection_model, 'confidence_level': st.session_state.confidence_level}
149
  st.session_state['model_loaded'] = True
 
150
  free_gpu_resources()
151
  except Exception as e:
152
  st.error(f"Error reloading model: {e}")
@@ -216,9 +218,11 @@ class StateManager:
216
  try:
217
  free_gpu_resources()
218
  if self.is_model_loaded():
 
219
  prepare_kbvqa_model(only_reload_detection_model=True)
220
  st.session_state['kbvqa'].detection_confidence = st.session_state.confidence_level
221
  self.col1.success("Model reloaded with updated settings and ready for inference.")
 
222
  free_gpu_resources()
223
  except Exception as e:
224
  st.error(f"Error reloading detection model: {e}")
 
139
 
140
  def force_reload_model(self):
141
  try:
142
+ st.session_state['loading_in_progress'] = True
143
  self.delete_model()
144
  self.initialize_state()
145
  free_gpu_resources()
 
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}
150
  st.session_state['model_loaded'] = True
151
+ st.session_state['loading_in_progress'] = False
152
  free_gpu_resources()
153
  except Exception as e:
154
  st.error(f"Error reloading model: {e}")
 
218
  try:
219
  free_gpu_resources()
220
  if self.is_model_loaded():
221
+ st.session_state['loading_in_progress'] = True
222
  prepare_kbvqa_model(only_reload_detection_model=True)
223
  st.session_state['kbvqa'].detection_confidence = st.session_state.confidence_level
224
  self.col1.success("Model reloaded with updated settings and ready for inference.")
225
+ st.session_state['loading_in_progress'] = False
226
  free_gpu_resources()
227
  except Exception as e:
228
  st.error(f"Error reloading detection model: {e}")