m7mdal7aj commited on
Commit
08655fb
1 Parent(s): 3d9562e

Update my_model/utilities/state_manager.py

Browse files
my_model/utilities/state_manager.py CHANGED
@@ -26,7 +26,13 @@ class StateManager:
26
  detection_model = st.selectbox("Choose a model for objects detection:", ["yolov5", "detic"], index=1, key='detection_model')
27
  default_confidence = 0.2 if st.session_state.detection_model == "yolov5" else 0.4
28
  self.set_slider_value(text="Select minimum detection confidence level", min_value=0.1, max_value=0.9, value=default_confidence, step=0.1, slider_key_name='confidence_level')
 
29
 
 
 
 
 
 
30
  def set_slider_value(self, text, min_value, max_value, value, step, slider_key_name):
31
 
32
  return st.slider(text, min_value, max_value, value, step, key=slider_key_name)
@@ -37,7 +43,7 @@ class StateManager:
37
 
38
  def display_model_settings(self):
39
  st.write("#### Current Model Settings:")
40
- data = [{'Key': key, 'Value': str(value)} for key, value in st.session_state.items() if key in ["confidence_level", 'detection_model', 'method', 'kbvqa']]
41
  df = pd.DataFrame(data)
42
  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')]}])
43
  st.table(styled_df)
 
26
  detection_model = st.selectbox("Choose a model for objects detection:", ["yolov5", "detic"], index=1, key='detection_model')
27
  default_confidence = 0.2 if st.session_state.detection_model == "yolov5" else 0.4
28
  self.set_slider_value(text="Select minimum detection confidence level", min_value=0.1, max_value=0.9, value=default_confidence, step=0.1, slider_key_name='confidence_level')
29
+ show_session_state = st.sidebar.checkbox("Show Session State", False)
30
 
31
+ # Conditional display of model settings
32
+ if show_session_state:
33
+ display_model_settings()
34
+
35
+
36
  def set_slider_value(self, text, min_value, max_value, value, step, slider_key_name):
37
 
38
  return st.slider(text, min_value, max_value, value, step, key=slider_key_name)
 
43
 
44
  def display_model_settings(self):
45
  st.write("#### Current Model Settings:")
46
+ 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', ]]
47
  df = pd.DataFrame(data)
48
  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')]}])
49
  st.table(styled_df)