Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -143,6 +143,9 @@ def process_submission(input_img, text_answer, country, state, city, se_asia_rel
|
|
143 |
location_info = f"Location: {city}, {state}, {country}" if state else f"Location: {city}, {country}"
|
144 |
return input_img, f"Your text response: {text_answer}", f"Selected location: {location_info}", f"SE Asia relevance: {se_asia_relevance}", f"Cultural knowledge source: {culture_knowledge}", f"Native caption: {native_caption}", f"English caption: {english_caption}"
|
145 |
|
|
|
|
|
|
|
146 |
# Initialize the dataset
|
147 |
setup_hf_dataset()
|
148 |
|
@@ -201,9 +204,14 @@ with gr.Blocks() as gradio_app:
|
|
201 |
with gr.Row():
|
202 |
english_caption = gr.Textbox(label="English Caption:", placeholder="Enter caption in English")
|
203 |
|
|
|
204 |
with gr.Row():
|
|
|
205 |
submit_btn = gr.Button("Submit")
|
206 |
|
|
|
|
|
|
|
207 |
with gr.Row():
|
208 |
output_img = gr.Image(label="Submitted Image")
|
209 |
|
@@ -255,6 +263,32 @@ with gr.Blocks() as gradio_app:
|
|
255 |
output_english
|
256 |
]
|
257 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
|
259 |
if __name__ == "__main__":
|
260 |
gradio_app.launch()
|
|
|
143 |
location_info = f"Location: {city}, {state}, {country}" if state else f"Location: {city}, {country}"
|
144 |
return input_img, f"Your text response: {text_answer}", f"Selected location: {location_info}", f"SE Asia relevance: {se_asia_relevance}", f"Cultural knowledge source: {culture_knowledge}", f"Native caption: {native_caption}", f"English caption: {english_caption}"
|
145 |
|
146 |
+
def clear_inputs():
|
147 |
+
return None, "", None, None, "", None, None, "", ""
|
148 |
+
|
149 |
# Initialize the dataset
|
150 |
setup_hf_dataset()
|
151 |
|
|
|
204 |
with gr.Row():
|
205 |
english_caption = gr.Textbox(label="English Caption:", placeholder="Enter caption in English")
|
206 |
|
207 |
+
# Add two rows of buttons as shown in the image
|
208 |
with gr.Row():
|
209 |
+
clear_btn = gr.Button("Clear")
|
210 |
submit_btn = gr.Button("Submit")
|
211 |
|
212 |
+
with gr.Row():
|
213 |
+
share_btn = gr.Button("Share via Link", variant="secondary", elem_classes=["share-button"])
|
214 |
+
|
215 |
with gr.Row():
|
216 |
output_img = gr.Image(label="Submitted Image")
|
217 |
|
|
|
263 |
output_english
|
264 |
]
|
265 |
)
|
266 |
+
|
267 |
+
clear_btn.click(
|
268 |
+
fn=clear_inputs,
|
269 |
+
inputs=[],
|
270 |
+
outputs=[
|
271 |
+
input_img,
|
272 |
+
text_answer,
|
273 |
+
country_dropdown,
|
274 |
+
state_dropdown,
|
275 |
+
city_textbox,
|
276 |
+
se_asia_relevance,
|
277 |
+
culture_knowledge,
|
278 |
+
native_caption,
|
279 |
+
english_caption
|
280 |
+
]
|
281 |
+
)
|
282 |
+
|
283 |
+
gr.HTML("""
|
284 |
+
<style>
|
285 |
+
.share-button {
|
286 |
+
background-color: #f0f0f0 !important;
|
287 |
+
color: #000 !important;
|
288 |
+
border: 1px solid #ccc !important;
|
289 |
+
}
|
290 |
+
</style>
|
291 |
+
""")
|
292 |
|
293 |
if __name__ == "__main__":
|
294 |
gradio_app.launch()
|