Update my_model/state_manager.py
Browse files
my_model/state_manager.py
CHANGED
@@ -42,10 +42,10 @@ class StateManager:
|
|
42 |
Sets up user interface widgets for selecting models, settings, and displaying model settings conditionally.
|
43 |
"""
|
44 |
disabled=st.session_state['loading_in_progress']
|
45 |
-
self.col1.selectbox("Choose a method:", ["Fine-Tuned Model", "In-Context Learning (n-shots)"], index=0, key='method', disabled=
|
46 |
-
detection_model = self.col1.selectbox("Choose a model for objects detection:", ["yolov5", "detic"], index=1, key='detection_model', disabled=
|
47 |
default_confidence = 0.2 if st.session_state.detection_model == "yolov5" else 0.4
|
48 |
-
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', col=self.col1, disabled=
|
49 |
|
50 |
# Conditional display of model settings
|
51 |
|
@@ -71,10 +71,13 @@ class StateManager:
|
|
71 |
"""
|
72 |
|
73 |
if col is None:
|
74 |
-
return st.slider(text, min_value, max_value, value, step, key=slider_key_name)
|
75 |
else:
|
76 |
-
return col.slider(text, min_value, max_value, value, step, key=slider_key_name)
|
77 |
|
|
|
|
|
|
|
78 |
|
79 |
@property
|
80 |
def settings_changed(self):
|
@@ -141,7 +144,6 @@ class StateManager:
|
|
141 |
try:
|
142 |
st.session_state['loading_in_progress'] = True
|
143 |
self.delete_model()
|
144 |
-
self.initialize_state()
|
145 |
free_gpu_resources()
|
146 |
st.session_state['kbvqa'] = prepare_kbvqa_model(force_reload=True)
|
147 |
st.session_state['kbvqa'].detection_confidence = st.session_state.confidence_level
|
|
|
42 |
Sets up user interface widgets for selecting models, settings, and displaying model settings conditionally.
|
43 |
"""
|
44 |
disabled=st.session_state['loading_in_progress']
|
45 |
+
self.col1.selectbox("Choose a method:", ["Fine-Tuned Model", "In-Context Learning (n-shots)"], index=0, key='method', disabled=self.is_widget_disabled)
|
46 |
+
detection_model = self.col1.selectbox("Choose a model for objects detection:", ["yolov5", "detic"], index=1, key='detection_model', disabled=self.is_widget_disabled)
|
47 |
default_confidence = 0.2 if st.session_state.detection_model == "yolov5" else 0.4
|
48 |
+
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', col=self.col1, disabled=self.is_widget_disabled)
|
49 |
|
50 |
# Conditional display of model settings
|
51 |
|
|
|
71 |
"""
|
72 |
|
73 |
if col is None:
|
74 |
+
return st.slider(text, min_value, max_value, value, step, key=slider_key_name, disabled=disabled)
|
75 |
else:
|
76 |
+
return col.slider(text, min_value, max_value, value, step, key=slider_key_name, disabled=disabled)
|
77 |
|
78 |
+
@property
|
79 |
+
def is_widget_disabled(self):
|
80 |
+
return st.session_state['loading_in_progress']
|
81 |
|
82 |
@property
|
83 |
def settings_changed(self):
|
|
|
144 |
try:
|
145 |
st.session_state['loading_in_progress'] = True
|
146 |
self.delete_model()
|
|
|
147 |
free_gpu_resources()
|
148 |
st.session_state['kbvqa'] = prepare_kbvqa_model(force_reload=True)
|
149 |
st.session_state['kbvqa'].detection_confidence = st.session_state.confidence_level
|