Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -27,6 +27,8 @@ def update_state_dropdown(country):
|
|
27 |
if country in states_by_country:
|
28 |
return gr.Dropdown(choices=states_by_country[country], label=f"State/Province in {country}:", interactive=True)
|
29 |
return gr.Dropdown(choices=[], label="State/Province:", interactive=True)
|
|
|
|
|
30 |
def process_submission(input_img, language, country, state, city, se_asia_relevance, culture_knowledge, native_caption, english_caption,code_mixed_caption,domain,email,other_language=None):
|
31 |
submission_id = str(uuid.uuid4())
|
32 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
@@ -65,7 +67,7 @@ with gr.Blocks(theme='1024m/1024m-1') as gradio_app:
|
|
65 |
with gr.Column(scale=1):
|
66 |
input_img = gr.Image(label="Upload an image", sources=['upload', 'webcam'], type="pil")
|
67 |
language = gr.Dropdown(choices=south_asian_languages, label="Language:", info="Select the native language relevant to the image", interactive=True,value=south_asian_languages[-1])
|
68 |
-
other_language = gr.Textbox(label="Other Language:",placeholder="Optional",info="Name of the language if not listed above")
|
69 |
country_dropdown = gr.Dropdown(choices=["None","India", "Pakistan", "Bangladesh", "Afghanistan", "Bhutan", "Nepal", "Sri Lanka"], label="Country where the image was taken:", interactive=True)
|
70 |
state_dropdown = gr.Dropdown(choices=[], label="State/Province:", interactive=True)
|
71 |
city_textbox = gr.Textbox(label="City where the image was taken:", placeholder="Enter city name")
|
@@ -90,6 +92,7 @@ with gr.Blocks(theme='1024m/1024m-1') as gradio_app:
|
|
90 |
output_knowledge = gr.Text(label="Cultural Knowledge Source")
|
91 |
output_native = gr.Text(label="Native Language Caption")
|
92 |
output_english = gr.Text(label="English Caption")
|
|
|
93 |
country_dropdown.change(fn=update_state_dropdown, inputs=country_dropdown, outputs=state_dropdown)
|
94 |
submit_btn.click(fn=process_submission, inputs=[input_img, language, country_dropdown, state_dropdown, city_textbox, se_asia_relevance, culture_knowledge, native_caption, english_caption,code_mixed_caption,domain, email_input,other_language], outputs=[output_img, output_text, output_location, output_relevance, output_knowledge, output_native, output_english])
|
95 |
clear_btn.click(fn=clear_inputs, inputs=[], outputs=[input_img, language,other_language, country_dropdown, state_dropdown, city_textbox, se_asia_relevance, culture_knowledge, native_caption, english_caption,code_mixed_caption,domain, email_input])
|
|
|
27 |
if country in states_by_country:
|
28 |
return gr.Dropdown(choices=states_by_country[country], label=f"State/Province in {country}:", interactive=True)
|
29 |
return gr.Dropdown(choices=[], label="State/Province:", interactive=True)
|
30 |
+
def update_other_language_visibility(selected_language):
|
31 |
+
return gr.update(visible=(selected_language == "OTHER"))
|
32 |
def process_submission(input_img, language, country, state, city, se_asia_relevance, culture_knowledge, native_caption, english_caption,code_mixed_caption,domain,email,other_language=None):
|
33 |
submission_id = str(uuid.uuid4())
|
34 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
|
67 |
with gr.Column(scale=1):
|
68 |
input_img = gr.Image(label="Upload an image", sources=['upload', 'webcam'], type="pil")
|
69 |
language = gr.Dropdown(choices=south_asian_languages, label="Language:", info="Select the native language relevant to the image", interactive=True,value=south_asian_languages[-1])
|
70 |
+
other_language = gr.Textbox(label="Other Language:", placeholder="Optional", info="Name of the language if not listed above", visible=False)
|
71 |
country_dropdown = gr.Dropdown(choices=["None","India", "Pakistan", "Bangladesh", "Afghanistan", "Bhutan", "Nepal", "Sri Lanka"], label="Country where the image was taken:", interactive=True)
|
72 |
state_dropdown = gr.Dropdown(choices=[], label="State/Province:", interactive=True)
|
73 |
city_textbox = gr.Textbox(label="City where the image was taken:", placeholder="Enter city name")
|
|
|
92 |
output_knowledge = gr.Text(label="Cultural Knowledge Source")
|
93 |
output_native = gr.Text(label="Native Language Caption")
|
94 |
output_english = gr.Text(label="English Caption")
|
95 |
+
language.change(update_other_language_visibility, inputs=language, outputs=other_language)
|
96 |
country_dropdown.change(fn=update_state_dropdown, inputs=country_dropdown, outputs=state_dropdown)
|
97 |
submit_btn.click(fn=process_submission, inputs=[input_img, language, country_dropdown, state_dropdown, city_textbox, se_asia_relevance, culture_knowledge, native_caption, english_caption,code_mixed_caption,domain, email_input,other_language], outputs=[output_img, output_text, output_location, output_relevance, output_knowledge, output_native, output_english])
|
98 |
clear_btn.click(fn=clear_inputs, inputs=[], outputs=[input_img, language,other_language, country_dropdown, state_dropdown, city_textbox, se_asia_relevance, culture_knowledge, native_caption, english_caption,code_mixed_caption,domain, email_input])
|