Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Fix Reset App button
Browse files
app.py
CHANGED
|
@@ -79,6 +79,10 @@ pipeline.to(device)
|
|
| 79 |
|
| 80 |
init_session_state()
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
st.markdown(
|
| 83 |
"<style>"
|
| 84 |
"details > summary { font-size: 1rem; font-weight: 500; }"
|
|
@@ -104,7 +108,7 @@ st.markdown(
|
|
| 104 |
"<p style='margin-bottom:4px;'>Keep in mind that this is a very early draft of the tool. "
|
| 105 |
"Please be patient with any bugs/errors, and email Connor Young at "
|
| 106 |
"<a href='mailto:czyoung@ualr.edu'>czyoung@ualr.edu</a> if you need help using the tool!</p>"
|
| 107 |
-
"<hr style='margin-top:16px; margin-bottom:
|
| 108 |
unsafe_allow_html=True,
|
| 109 |
)
|
| 110 |
|
|
@@ -123,6 +127,7 @@ with st.expander("Instructions and additional details"):
|
|
| 123 |
uploaded_file_paths = st.file_uploader(
|
| 124 |
"Upload an audio of classroom activity to analyze",
|
| 125 |
accept_multiple_files=True,
|
|
|
|
| 126 |
)
|
| 127 |
|
| 128 |
temp_dir = tempfile.mkdtemp()
|
|
@@ -171,8 +176,10 @@ else:
|
|
| 171 |
st.session_state.analyzeAllToggle = True
|
| 172 |
with col_reset:
|
| 173 |
if st.button("🗑️ Reset App", key="button_reset", type="secondary", use_container_width=True):
|
|
|
|
| 174 |
for key in list(st.session_state.keys()):
|
| 175 |
del st.session_state[key]
|
|
|
|
| 176 |
st.rerun()
|
| 177 |
|
| 178 |
# ---------------------------------------------------------------------------
|
|
@@ -352,4 +359,4 @@ with st.expander("(Potentially) FAQ"):
|
|
| 352 |
|
| 353 |
st.divider()
|
| 354 |
st.write("Would you like additional data, charts, or features? [Tell us about our project!](https://forms.gle/A32CdfGYSZoMPyyX9)")
|
| 355 |
-
st.write("If you would like to learn more or work with us, contact Dr. Mark Baillie at mtbaillie@ualr.edu")
|
|
|
|
| 79 |
|
| 80 |
init_session_state()
|
| 81 |
|
| 82 |
+
# Uploader key is rotated on reset to force the widget to clear
|
| 83 |
+
if "uploader_key" not in st.session_state:
|
| 84 |
+
st.session_state.uploader_key = 0
|
| 85 |
+
|
| 86 |
st.markdown(
|
| 87 |
"<style>"
|
| 88 |
"details > summary { font-size: 1rem; font-weight: 500; }"
|
|
|
|
| 108 |
"<p style='margin-bottom:4px;'>Keep in mind that this is a very early draft of the tool. "
|
| 109 |
"Please be patient with any bugs/errors, and email Connor Young at "
|
| 110 |
"<a href='mailto:czyoung@ualr.edu'>czyoung@ualr.edu</a> if you need help using the tool!</p>"
|
| 111 |
+
"<hr style='margin-top:16px; margin-bottom:16px;'>",
|
| 112 |
unsafe_allow_html=True,
|
| 113 |
)
|
| 114 |
|
|
|
|
| 127 |
uploaded_file_paths = st.file_uploader(
|
| 128 |
"Upload an audio of classroom activity to analyze",
|
| 129 |
accept_multiple_files=True,
|
| 130 |
+
key=f"uploader_{st.session_state.uploader_key}",
|
| 131 |
)
|
| 132 |
|
| 133 |
temp_dir = tempfile.mkdtemp()
|
|
|
|
| 176 |
st.session_state.analyzeAllToggle = True
|
| 177 |
with col_reset:
|
| 178 |
if st.button("🗑️ Reset App", key="button_reset", type="secondary", use_container_width=True):
|
| 179 |
+
next_key = st.session_state.uploader_key + 1
|
| 180 |
for key in list(st.session_state.keys()):
|
| 181 |
del st.session_state[key]
|
| 182 |
+
st.session_state.uploader_key = next_key
|
| 183 |
st.rerun()
|
| 184 |
|
| 185 |
# ---------------------------------------------------------------------------
|
|
|
|
| 359 |
|
| 360 |
st.divider()
|
| 361 |
st.write("Would you like additional data, charts, or features? [Tell us about our project!](https://forms.gle/A32CdfGYSZoMPyyX9)")
|
| 362 |
+
st.write("If you would like to learn more or work with us, contact Dr. Mark Baillie at mtbaillie@ualr.edu")
|