Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,31 @@ import pandas as pd, numpy as np
|
|
| 5 |
from transformers import CLIPProcessor, CLIPModel
|
| 6 |
from st_clickable_images import clickable_images
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
@st.cache(
|
| 10 |
show_spinner=False,
|
|
|
|
| 5 |
from transformers import CLIPProcessor, CLIPModel
|
| 6 |
from st_clickable_images import clickable_images
|
| 7 |
|
| 8 |
+
# callback to update query param on selectbox change
|
| 9 |
+
def update_params():
|
| 10 |
+
try:
|
| 11 |
+
print("update1")
|
| 12 |
+
#st.experimental_set_query_params(option=st.session_state.query)
|
| 13 |
+
except ValueError:
|
| 14 |
+
pass
|
| 15 |
+
|
| 16 |
+
# RADIO BUTTON SET PERSIST
|
| 17 |
+
# radio button persistance - plan is to hydrate when selected and change url along with textbox and search
|
| 18 |
+
options = ["artificial intelligence", "robot", "software", "AI", "VR", "medicine", "alien", "psychology", "fantasy", "cyber", "genomics", "animation", "sci-fi"] # these options come from my research interests blended with keywords across film genres
|
| 19 |
+
|
| 20 |
+
query_params = st.experimental_get_query_params()
|
| 21 |
+
ix = 0
|
| 22 |
+
if query_params:
|
| 23 |
+
try:
|
| 24 |
+
q0 = query_params['query'][0]
|
| 25 |
+
ix = options.index(q0)
|
| 26 |
+
except ValueError:
|
| 27 |
+
pass
|
| 28 |
+
selected_option = st.radio(
|
| 29 |
+
"Param", options, index=ix, key="query", on_change=update_params
|
| 30 |
+
)
|
| 31 |
+
st.experimental_set_query_params(option=selected_option)
|
| 32 |
+
|
| 33 |
|
| 34 |
@st.cache(
|
| 35 |
show_spinner=False,
|