Spaces:
Running
Running
Update my_model/state_manager.py
Browse files- my_model/state_manager.py +17 -13
my_model/state_manager.py
CHANGED
@@ -25,23 +25,27 @@ class StateManager:
|
|
25 |
|
26 |
# Create two columns with different widths
|
27 |
col1, col2, col3 = st.columns([0.2, 0.6, 0.2]) # Adjust the ratio as needed
|
28 |
-
|
29 |
-
col1
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
33 |
|
34 |
# Conditional display of model settings
|
35 |
-
|
36 |
-
show_model_settings = col3.checkbox("Show Model Settings", False)
|
37 |
-
if show_model_settings:
|
38 |
-
self.display_model_settings()
|
39 |
|
|
|
|
|
|
|
|
|
40 |
|
41 |
-
|
42 |
-
def set_slider_value(self, text, min_value, max_value, value, step, slider_key_name, col):
|
43 |
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
|
47 |
@property
|
@@ -50,7 +54,7 @@ class StateManager:
|
|
50 |
|
51 |
|
52 |
def display_model_settings(self):
|
53 |
-
st.write("
|
54 |
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', ]]
|
55 |
df = pd.DataFrame(data)
|
56 |
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')]}])
|
|
|
25 |
|
26 |
# Create two columns with different widths
|
27 |
col1, col2, col3 = st.columns([0.2, 0.6, 0.2]) # Adjust the ratio as needed
|
28 |
+
|
29 |
+
with col1:
|
30 |
+
st.selectbox("Choose a method:", ["Fine-Tuned Model", "In-Context Learning (n-shots)"], index=0, key='method')
|
31 |
+
detection_model = st.selectbox("Choose a model for objects detection:", ["yolov5", "detic"], index=1, key='detection_model')
|
32 |
+
default_confidence = 0.2 if st.session_state.detection_model == "yolov5" else 0.4
|
33 |
+
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')
|
34 |
|
35 |
# Conditional display of model settings
|
|
|
|
|
|
|
|
|
36 |
|
37 |
+
with col3:
|
38 |
+
show_model_settings = st.checkbox("Show Model Settings", False)
|
39 |
+
if show_model_settings:
|
40 |
+
self.display_model_settings()
|
41 |
|
|
|
|
|
42 |
|
43 |
+
|
44 |
+
def set_slider_value(self, text, min_value, max_value, value, step, slider_key_name, col=None):
|
45 |
+
if col is None:
|
46 |
+
return st.slider(text, min_value, max_value, value, step, key=slider_key_name)
|
47 |
+
else:
|
48 |
+
return col.slider(text, min_value, max_value, value, step, key=slider_key_name)
|
49 |
|
50 |
|
51 |
@property
|
|
|
54 |
|
55 |
|
56 |
def display_model_settings(self):
|
57 |
+
st.write("##### Current Model Settings:")
|
58 |
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', ]]
|
59 |
df = pd.DataFrame(data)
|
60 |
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')]}])
|