Spaces:
Runtime error
Runtime error
Commit
·
0c09fe8
1
Parent(s):
71edabc
Update app.py
Browse files
app.py
CHANGED
|
@@ -108,6 +108,8 @@ def main():
|
|
| 108 |
|
| 109 |
# Check the model to use
|
| 110 |
option = st.selectbox("Select a model to use:", models_available)
|
|
|
|
|
|
|
| 111 |
|
| 112 |
# Load the selected trained model
|
| 113 |
if option in ("BERT-based model", "DistilBERT-based model (BERT light)"):
|
|
@@ -133,27 +135,6 @@ def main():
|
|
| 133 |
if text.strip() == "":
|
| 134 |
st.error("Please enter some text")
|
| 135 |
else:
|
| 136 |
-
# # Add a progress bar
|
| 137 |
-
# progress_bar = st.progress(0)
|
| 138 |
-
|
| 139 |
-
# # Add a placeholder for the progress message
|
| 140 |
-
# status_text = st.empty()
|
| 141 |
-
|
| 142 |
-
# # Simulate a long-running process
|
| 143 |
-
# for i in range(100):
|
| 144 |
-
# # Update the progress bar every 0.02 seconds
|
| 145 |
-
# time.sleep(0.05)
|
| 146 |
-
# progress_bar.progress(i + 1)
|
| 147 |
-
|
| 148 |
-
# if i % 2 == 0:
|
| 149 |
-
# magic = "✨"
|
| 150 |
-
# else:
|
| 151 |
-
# magic = ""
|
| 152 |
-
# # Update the progress message
|
| 153 |
-
# status_text.write(f"Work in progress {i + 1}%... Wait for the magic 🪄🔮{magic}")
|
| 154 |
-
# # Clear the progress bar and status message
|
| 155 |
-
# progress_bar.empty()
|
| 156 |
-
# status_text.empty()
|
| 157 |
with st.spinner("Wait for the magic 🪄🔮"):
|
| 158 |
# Use model
|
| 159 |
if option in ("Naive Bayes", "Logistic Regression"):
|
|
@@ -171,18 +152,12 @@ def main():
|
|
| 171 |
st.session_state["text"] = text
|
| 172 |
|
| 173 |
# Print result
|
| 174 |
-
# st.write(f"<span style='font-size: 24px;'>I think this text is: {prediction}</span>",
|
| 175 |
-
# unsafe_allow_html=True)
|
| 176 |
st.markdown(f"I think this text is: **:{st.session_state['color_pred']}[{st.session_state['prediction']}]** (Prediction probability: {st.session_state['predict_proba'] * 100}%)")
|
| 177 |
-
# help=f"I estimate that its probability is {st.session_state['predict_proba'] * 100}%")
|
| 178 |
|
| 179 |
elif "prediction" in st.session_state:
|
| 180 |
-
# Display the stored result if available
|
| 181 |
-
# st.write(f"<span style='font-size: 24px;'>I think this text is: {st.session_state['prediction']}</span>", unsafe_allow_html=True)
|
| 182 |
-
|
| 183 |
st.markdown(f"I think this text is: **:{st.session_state['color_pred']}[{st.session_state['prediction']}]** (Prediction probability: {st.session_state['predict_proba'] * 100}%)")
|
| 184 |
-
|
| 185 |
-
#**:blue[colored]**
|
| 186 |
if st.button("Model Explanation"):
|
| 187 |
# Check if there's text in the session state
|
| 188 |
if "text" in st.session_state:
|
|
|
|
| 108 |
|
| 109 |
# Check the model to use
|
| 110 |
option = st.selectbox("Select a model to use:", models_available)
|
| 111 |
+
if option and "prediction" in st.session_state:
|
| 112 |
+
del st.session_state.prediction
|
| 113 |
|
| 114 |
# Load the selected trained model
|
| 115 |
if option in ("BERT-based model", "DistilBERT-based model (BERT light)"):
|
|
|
|
| 135 |
if text.strip() == "":
|
| 136 |
st.error("Please enter some text")
|
| 137 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
with st.spinner("Wait for the magic 🪄🔮"):
|
| 139 |
# Use model
|
| 140 |
if option in ("Naive Bayes", "Logistic Regression"):
|
|
|
|
| 152 |
st.session_state["text"] = text
|
| 153 |
|
| 154 |
# Print result
|
|
|
|
|
|
|
| 155 |
st.markdown(f"I think this text is: **:{st.session_state['color_pred']}[{st.session_state['prediction']}]** (Prediction probability: {st.session_state['predict_proba'] * 100}%)")
|
|
|
|
| 156 |
|
| 157 |
elif "prediction" in st.session_state:
|
| 158 |
+
# Display the stored result if available
|
|
|
|
|
|
|
| 159 |
st.markdown(f"I think this text is: **:{st.session_state['color_pred']}[{st.session_state['prediction']}]** (Prediction probability: {st.session_state['predict_proba'] * 100}%)")
|
| 160 |
+
|
|
|
|
| 161 |
if st.button("Model Explanation"):
|
| 162 |
# Check if there's text in the session state
|
| 163 |
if "text" in st.session_state:
|