Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -87,12 +87,12 @@ def geolocate_text_byt5(text):
|
|
| 87 |
logits, (lat, lon) = model(input_tensor.unsqueeze(0), return_coordinates=True)
|
| 88 |
return lat, lon
|
| 89 |
|
| 90 |
-
if '
|
| 91 |
-
st.session_state.
|
| 92 |
|
| 93 |
# When an example button is clicked, update the session state
|
| 94 |
def set_example_text(example_text):
|
| 95 |
-
st.session_state.
|
| 96 |
|
| 97 |
example_texts = [
|
| 98 |
"Disfrutando de una paella deliciosa en las playas de #Valencia 🥘☀️",
|
|
@@ -112,9 +112,10 @@ for example in example_texts:
|
|
| 112 |
set_example_text(example)
|
| 113 |
|
| 114 |
# Get text input and update session state when it's modified
|
| 115 |
-
text_input = st.text_input('Enter your text:', value=st.session_state.
|
| 116 |
-
st.session_state.
|
| 117 |
-
|
|
|
|
| 118 |
if text_input:
|
| 119 |
location = geolocate_text_byt5(text_input)
|
| 120 |
st.write('Predicted Location: ', location)
|
|
|
|
| 87 |
logits, (lat, lon) = model(input_tensor.unsqueeze(0), return_coordinates=True)
|
| 88 |
return lat, lon
|
| 89 |
|
| 90 |
+
if 'text_input_state' not in st.session_state:
|
| 91 |
+
st.session_state.text_input_state = ""
|
| 92 |
|
| 93 |
# When an example button is clicked, update the session state
|
| 94 |
def set_example_text(example_text):
|
| 95 |
+
st.session_state.text_input_state = example_text
|
| 96 |
|
| 97 |
example_texts = [
|
| 98 |
"Disfrutando de una paella deliciosa en las playas de #Valencia 🥘☀️",
|
|
|
|
| 112 |
set_example_text(example)
|
| 113 |
|
| 114 |
# Get text input and update session state when it's modified
|
| 115 |
+
text_input = st.text_input('Enter your text:', value=st.session_state.text_input_state)
|
| 116 |
+
if text_input != st.session_state.text_input_state:
|
| 117 |
+
st.session_state.text_input_state = text_input
|
| 118 |
+
|
| 119 |
if text_input:
|
| 120 |
location = geolocate_text_byt5(text_input)
|
| 121 |
st.write('Predicted Location: ', location)
|