Spaces:
Running
Running
[text2image] suggestions without session_state
Browse files- text2image.py +21 -19
text2image.py
CHANGED
@@ -111,39 +111,41 @@ def app():
|
|
111 |
|
112 |
π€ Italian mode on! π€
|
113 |
|
|
|
|
|
114 |
"""
|
115 |
)
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
|
|
122 |
|
123 |
-
col1, col2, col3, col4 = st.beta_columns(
|
124 |
with col1:
|
125 |
-
st.button(
|
|
|
126 |
with col2:
|
127 |
-
st.button(
|
|
|
128 |
with col3:
|
129 |
-
st.button(
|
130 |
-
|
131 |
-
on_click=update_query,
|
132 |
-
kwargs=dict(value="Un fiore giallo"),
|
133 |
-
)
|
134 |
with col4:
|
135 |
-
st.button(
|
136 |
-
|
137 |
-
)
|
138 |
|
139 |
col1, col2 = st.beta_columns([3, 1])
|
140 |
with col1:
|
141 |
-
query = st.text_input(
|
142 |
-
"Insert an italian query text here...", st.session_state.suggestion
|
143 |
-
)
|
144 |
with col2:
|
145 |
dataset_name = st.selectbox("IR dataset", ["Unsplash", "CC"])
|
146 |
|
|
|
|
|
147 |
if query:
|
148 |
with st.spinner("Computing..."):
|
149 |
|
|
|
111 |
|
112 |
π€ Italian mode on! π€
|
113 |
|
114 |
+
|
115 |
+
You can choose one of our examples down below...
|
116 |
"""
|
117 |
)
|
118 |
|
119 |
+
suggestions = [
|
120 |
+
"Un gatto",
|
121 |
+
"Due gatti",
|
122 |
+
"Un fiore giallo",
|
123 |
+
"Un gatto sopra una sedia",
|
124 |
+
]
|
125 |
+
sugg_idx = -1
|
126 |
|
127 |
+
col1, col2, col3, col4 = st.beta_columns([1, 1, 1, 2])
|
128 |
with col1:
|
129 |
+
if st.button(suggestions[0]):
|
130 |
+
sugg_idx = 0
|
131 |
with col2:
|
132 |
+
if st.button(suggestions[1]):
|
133 |
+
sugg_idx = 1
|
134 |
with col3:
|
135 |
+
if st.button(suggestions[2]):
|
136 |
+
sugg_idx = 2
|
|
|
|
|
|
|
137 |
with col4:
|
138 |
+
if st.button(suggestions[3]):
|
139 |
+
sugg_idx = 3
|
|
|
140 |
|
141 |
col1, col2 = st.beta_columns([3, 1])
|
142 |
with col1:
|
143 |
+
query = st.text_input("... or insert an Italian query text")
|
|
|
|
|
144 |
with col2:
|
145 |
dataset_name = st.selectbox("IR dataset", ["Unsplash", "CC"])
|
146 |
|
147 |
+
query = query if query else suggestions[sugg_idx] if sugg_idx > -1 else ""
|
148 |
+
|
149 |
if query:
|
150 |
with st.spinner("Computing..."):
|
151 |
|