Spaces:
Running
Running
updated city and state
Browse files
app.py
CHANGED
@@ -107,16 +107,23 @@ setup_hf_dataset()
|
|
107 |
gradio_app = gr.Interface(
|
108 |
process_submission,
|
109 |
inputs=[
|
110 |
-
|
111 |
-
gr.
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
choices=[
|
121 |
"Yes. Unique to South Asia",
|
122 |
"Yes, people will likely think of South Asia when seeing the picture, but it may have low degree of similarity to other cultures.",
|
@@ -125,17 +132,57 @@ gradio_app = gr.Interface(
|
|
125 |
"No. Totally unrelated to South Asia"
|
126 |
],
|
127 |
label="Is the image culturally relevant in South Asia?"
|
128 |
-
)
|
129 |
-
|
|
|
130 |
choices=[
|
131 |
"I'm from this country/culture",
|
132 |
"I checked online resources (e.g., Wikipedia, articles, blogs)"
|
133 |
],
|
134 |
label="How do you know about this culture?",
|
135 |
-
info="Please do not consult LLMs
|
136 |
-
)
|
137 |
-
|
138 |
-
gr.Textbox(label="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
],
|
140 |
outputs=[
|
141 |
gr.Image(label="Submitted Image"),
|
|
|
107 |
gradio_app = gr.Interface(
|
108 |
process_submission,
|
109 |
inputs=[
|
110 |
+
with gr.Blocks() as gradio_app:
|
111 |
+
selected_country = gr.Dropdown(
|
112 |
+
choices=list(country_to_states.keys()),
|
113 |
+
label="Country where the image was taken:",
|
114 |
+
interactive=True
|
115 |
+
)
|
116 |
+
selected_state = gr.Dropdown(
|
117 |
+
choices=[],
|
118 |
+
label="State / Province",
|
119 |
+
interactive=True
|
120 |
+
)
|
121 |
+
city_field = gr.Textbox(label="City (optional)")
|
122 |
+
|
123 |
+
image_input = gr.Image(label="Upload an image", sources=['upload', 'webcam'], type="pil")
|
124 |
+
cultural_text = gr.Textbox(label="The image portrays culturally-relevant information in:")
|
125 |
+
|
126 |
+
sa_relevance = gr.Radio(
|
127 |
choices=[
|
128 |
"Yes. Unique to South Asia",
|
129 |
"Yes, people will likely think of South Asia when seeing the picture, but it may have low degree of similarity to other cultures.",
|
|
|
132 |
"No. Totally unrelated to South Asia"
|
133 |
],
|
134 |
label="Is the image culturally relevant in South Asia?"
|
135 |
+
)
|
136 |
+
|
137 |
+
knowledge_source = gr.Radio(
|
138 |
choices=[
|
139 |
"I'm from this country/culture",
|
140 |
"I checked online resources (e.g., Wikipedia, articles, blogs)"
|
141 |
],
|
142 |
label="How do you know about this culture?",
|
143 |
+
info="Please do not consult LLMs"
|
144 |
+
)
|
145 |
+
|
146 |
+
native_caption = gr.Textbox(label="Caption in Native Language:")
|
147 |
+
english_caption = gr.Textbox(label="English Caption:")
|
148 |
+
|
149 |
+
output_components = [
|
150 |
+
gr.Image(label="Submitted Image"),
|
151 |
+
gr.Text(label="Text Response"),
|
152 |
+
gr.Text(label="Country and State"),
|
153 |
+
gr.Text(label="Location Information"),
|
154 |
+
gr.Text(label="South Asia Cultural Relevance"),
|
155 |
+
gr.Text(label="Cultural Knowledge Source"),
|
156 |
+
gr.Text(label="Native Language Caption"),
|
157 |
+
gr.Text(label="English Caption")
|
158 |
+
]
|
159 |
+
|
160 |
+
# Link dynamic dropdown update
|
161 |
+
def update_states(selected_country):
|
162 |
+
return gr.Dropdown.update(choices=country_to_states.get(selected_country, []), value=None)
|
163 |
+
|
164 |
+
selected_country.change(fn=update_states, inputs=selected_country, outputs=selected_state)
|
165 |
+
|
166 |
+
submit_btn = gr.Button("Submit")
|
167 |
+
|
168 |
+
submit_btn.click(
|
169 |
+
process_submission,
|
170 |
+
inputs=[
|
171 |
+
image_input,
|
172 |
+
cultural_text,
|
173 |
+
selected_country,
|
174 |
+
selected_state,
|
175 |
+
city_field,
|
176 |
+
sa_relevance,
|
177 |
+
knowledge_source,
|
178 |
+
native_caption,
|
179 |
+
english_caption
|
180 |
+
],
|
181 |
+
outputs=output_components
|
182 |
+
)
|
183 |
+
|
184 |
+
gr.Markdown("## South Asian Image Data Collection")
|
185 |
+
gr.Markdown("Upload an image and answer questions about its cultural significance.")
|
186 |
],
|
187 |
outputs=[
|
188 |
gr.Image(label="Submitted Image"),
|