Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -87,8 +87,11 @@ 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):
|
@@ -109,15 +112,14 @@ st.title('GeoTagging using ByT5')
|
|
109 |
st.write('Examples:')
|
110 |
for example in example_texts:
|
111 |
if st.button(f"{example}"):
|
112 |
-
st.session_state.
|
|
|
113 |
|
114 |
# Get text input and update session state when it's modified
|
115 |
-
|
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)
|
122 |
|
123 |
# Render map with pydeck
|
|
|
87 |
logits, (lat, lon) = model(input_tensor.unsqueeze(0), return_coordinates=True)
|
88 |
return lat, lon
|
89 |
|
90 |
+
if 'text_input' not in st.session_state:
|
91 |
+
st.session_state.text_input = ""
|
92 |
+
|
93 |
+
if 'text_modified' not in st.session_state:
|
94 |
+
st.session_state.text_modified = ""
|
95 |
|
96 |
# When an example button is clicked, update the session state
|
97 |
def set_example_text(example_text):
|
|
|
112 |
st.write('Examples:')
|
113 |
for example in example_texts:
|
114 |
if st.button(f"{example}"):
|
115 |
+
st.session_state.text_input = example
|
116 |
+
st.session_state.text_modified = st.session_state.text_input
|
117 |
|
118 |
# Get text input and update session state when it's modified
|
119 |
+
st.session_state.text_modified = st.text_input('Enter your text:', value=st.session_state.text_input)
|
|
|
|
|
120 |
|
121 |
+
if st.session_state.text_input:
|
122 |
+
location = geolocate_text_byt5(st.session_state.text_input)
|
123 |
st.write('Predicted Location: ', location)
|
124 |
|
125 |
# Render map with pydeck
|