testing a more compact demo
Browse files
app.py
CHANGED
@@ -125,47 +125,48 @@ def render_experiment(query):
|
|
125 |
f"{CLASSIFIER_TAG}-Output"
|
126 |
]
|
127 |
|
128 |
-
################################### SHOW DESCRIPTION OF CLASS
|
129 |
-
with st.expander("Show Class Description"):
|
130 |
-
st.write(f"**Name**: {prediction_label}")
|
131 |
-
st.write("**Class Definition**:")
|
132 |
-
st.markdown("`" + class_def + "`")
|
133 |
-
st.image(
|
134 |
-
Image.open(f"demonstrations/{predicted_wnid}.jpeg"),
|
135 |
-
caption=f"Class Explanation",
|
136 |
-
use_column_width=True,
|
137 |
-
)
|
138 |
-
|
139 |
################################### SHOW QUERY and PREDICTION
|
140 |
-
with st.expander("Show Query"):
|
141 |
-
col1, col2 = st.columns(2)
|
142 |
-
with col1:
|
143 |
-
st.image(load_query(current_query), caption=f"Query ID: {query_id}")
|
144 |
-
with col2:
|
145 |
-
default_value = 0
|
146 |
-
if query_id in session_state.user_feedback.keys():
|
147 |
-
if session_state.user_feedback[query_id] == "Correct":
|
148 |
-
default_value = 1
|
149 |
-
elif session_state.user_feedback[query_id] == "Wrong":
|
150 |
-
default_value = 2
|
151 |
-
|
152 |
-
session_state.user_feedback[query_id] = st.radio(
|
153 |
-
"What do you think about model's prediction?",
|
154 |
-
("-", "Correct", "Wrong"),
|
155 |
-
key=query_id,
|
156 |
-
index=default_value,
|
157 |
-
)
|
158 |
-
st.write(f"**Model Prediction**: {prediction_label}")
|
159 |
-
st.write(f"**Model Confidence**: {prediction_confidence}")
|
160 |
|
161 |
-
|
162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
st.image(
|
164 |
-
|
165 |
-
caption=f"
|
166 |
use_column_width=True,
|
167 |
)
|
168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
################################### SHOW DEBUG INFO
|
170 |
|
171 |
if st.button("Debug: Show Everything"):
|
|
|
125 |
f"{CLASSIFIER_TAG}-Output"
|
126 |
]
|
127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
################################### SHOW QUERY and PREDICTION
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
|
130 |
+
col1, col2 = st.columns(2)
|
131 |
+
with col1:
|
132 |
+
st.image(load_query(current_query), caption=f"Query ID: {query_id}")
|
133 |
+
with col2:
|
134 |
+
################################### SHOW DESCRIPTION OF CLASS
|
135 |
+
with st.expander("Show Class Description"):
|
136 |
+
st.write(f"**Name**: {prediction_label}")
|
137 |
+
st.write("**Class Definition**:")
|
138 |
+
st.markdown("`" + class_def + "`")
|
139 |
st.image(
|
140 |
+
Image.open(f"demonstrations/{predicted_wnid}.jpeg"),
|
141 |
+
caption=f"Class Explanation",
|
142 |
use_column_width=True,
|
143 |
)
|
144 |
|
145 |
+
|
146 |
+
default_value = 0
|
147 |
+
if query_id in session_state.user_feedback.keys():
|
148 |
+
if session_state.user_feedback[query_id] == "Correct":
|
149 |
+
default_value = 1
|
150 |
+
elif session_state.user_feedback[query_id] == "Wrong":
|
151 |
+
default_value = 2
|
152 |
+
|
153 |
+
session_state.user_feedback[query_id] = st.radio(
|
154 |
+
"What do you think about model's prediction?",
|
155 |
+
("-", "Correct", "Wrong"),
|
156 |
+
key=query_id,
|
157 |
+
index=default_value,
|
158 |
+
)
|
159 |
+
st.write(f"**Model Prediction**: {prediction_label}")
|
160 |
+
st.write(f"**Model Confidence**: {prediction_confidence}")
|
161 |
+
|
162 |
+
################################### SHOW Model Explanation
|
163 |
+
if selected_xai_tool is not None:
|
164 |
+
st.image(
|
165 |
+
selected_xai_tool(current_query),
|
166 |
+
caption=f"Explaination",
|
167 |
+
use_column_width=True,
|
168 |
+
)
|
169 |
+
|
170 |
################################### SHOW DEBUG INFO
|
171 |
|
172 |
if st.button("Debug: Show Everything"):
|