m7mdal7aj commited on
Commit
ffdb10e
1 Parent(s): d7c0f13

Update my_model/state_manager.py

Browse files
Files changed (1) hide show
  1. my_model/state_manager.py +13 -2
my_model/state_manager.py CHANGED
@@ -3,7 +3,7 @@ import copy
3
  from PIL import Image
4
  import streamlit as st
5
  from my_model.utilities.gen_utilities import free_gpu_resources
6
- from my_model.KBVQA import KBVQA, prepare_kbvqa_model
7
 
8
 
9
 
@@ -130,7 +130,18 @@ class StateManager:
130
  except Exception as e:
131
  st.error(f"Error loading model: {e}")
132
 
133
-
 
 
 
 
 
 
 
 
 
 
 
134
  # Function to check if any session state values have changed
135
  def has_state_changed(self):
136
  """
 
3
  from PIL import Image
4
  import streamlit as st
5
  from my_model.utilities.gen_utilities import free_gpu_resources
6
+ from my_model.KBVQA import KBVQA, prepare_kbvqa_model, force_reload_model
7
 
8
 
9
 
 
130
  except Exception as e:
131
  st.error(f"Error loading model: {e}")
132
 
133
+ def force_reload_kbvqa(self):
134
+ try:
135
+ free_gpu_resources()
136
+ st.session_state['kbvqa'] = force_reload_model()
137
+ st.session_state['kbvqa'].detection_confidence = st.session_state.confidence_level
138
+ # Update the previous state with current session state values
139
+ st.session_state['previous_state'] = {'method': st.session_state.method, 'detection_model': st.session_state.detection_model, 'confidence_level': st.session_state.confidence_level}
140
+ st.session_state['model_loaded'] = True
141
+ except Exception as e:
142
+ st.error(f"Error loading model: {e}")
143
+
144
+
145
  # Function to check if any session state values have changed
146
  def has_state_changed(self):
147
  """