m7mdal7aj commited on
Commit
a264403
1 Parent(s): 3e07f22

Update my_model/state_manager.py

Browse files
Files changed (1) hide show
  1. my_model/state_manager.py +7 -5
my_model/state_manager.py CHANGED
@@ -25,6 +25,11 @@ class StateManager:
25
  st.session_state['previous_state'] = {}
26
  if "settings_changed" not in st.session_state:
27
  st.session_state['settings_changed'] = self.settings_changed
 
 
 
 
 
28
 
29
 
30
 
@@ -87,7 +92,7 @@ class StateManager:
87
  self.col3.write("##### Current Model Settings:")
88
  data = [{'Key': key, 'Value': str(value)} for key, value in st.session_state.items() if key in ["confidence_level", 'detection_model', 'method', 'kbvqa', 'previous_state', 'settings_changed', ]]
89
  df = pd.DataFrame(data)
90
- styled_df = df.style.set_properties(**{'background-color': 'black', 'color': 'white', 'border-color': 'white'}).set_table_styles([{'selector': 'th','props': [('background-color', 'black'), ('font-weight', 'bold')]}])
91
  self.col3.table(styled_df)
92
 
93
 
@@ -117,13 +122,10 @@ class StateManager:
117
  free_gpu_resources()
118
  st.session_state['kbvqa'] = prepare_kbvqa_model()
119
  st.session_state['kbvqa'].detection_confidence = st.session_state.confidence_level
120
-
121
  # Update the previous state with current session state values
122
  st.session_state['previous_state'] = {'method': st.session_state.method, 'detection_model': st.session_state.detection_model, 'confidence_level': st.session_state.confidence_level}
123
-
124
  st.session_state['button_label'] = "Reload Model"
125
- #st.text('button changed')
126
- #self.has_state_changed()
127
  free_gpu_resources()
128
  except Exception as e:
129
  st.error(f"Error loading model: {e}")
 
25
  st.session_state['previous_state'] = {}
26
  if "settings_changed" not in st.session_state:
27
  st.session_state['settings_changed'] = self.settings_changed
28
+ if 'model_loaded' not in st.session_state:
29
+ st.session_state['model_loaded'] = False
30
+ if 'loading_in_progress' not in st.session_state:
31
+ st.session_state['loading_in_progress'] = False
32
+
33
 
34
 
35
 
 
92
  self.col3.write("##### Current Model Settings:")
93
  data = [{'Key': key, 'Value': str(value)} for key, value in st.session_state.items() if key in ["confidence_level", 'detection_model', 'method', 'kbvqa', 'previous_state', 'settings_changed', ]]
94
  df = pd.DataFrame(data)
95
+ styled_df = df.style.set_properties(**{'background-color': 'white', 'color': 'black', 'border-color': 'black'}).set_table_styles([{'selector': 'th','props': [('background-color', 'gray'), ('font-weight', 'bold')]}])
96
  self.col3.table(styled_df)
97
 
98
 
 
122
  free_gpu_resources()
123
  st.session_state['kbvqa'] = prepare_kbvqa_model()
124
  st.session_state['kbvqa'].detection_confidence = st.session_state.confidence_level
 
125
  # Update the previous state with current session state values
126
  st.session_state['previous_state'] = {'method': st.session_state.method, 'detection_model': st.session_state.detection_model, 'confidence_level': st.session_state.confidence_level}
127
+ st.session_state['model_loaded'] = True
128
  st.session_state['button_label'] = "Reload Model"
 
 
129
  free_gpu_resources()
130
  except Exception as e:
131
  st.error(f"Error loading model: {e}")