minemaster01 commited on
Commit
0bd155b
·
verified ·
1 Parent(s): 2a88122

updated city and state

Browse files
Files changed (1) hide show
  1. app.py +63 -16
app.py CHANGED
@@ -107,16 +107,23 @@ setup_hf_dataset()
107
  gradio_app = gr.Interface(
108
  process_submission,
109
  inputs=[
110
- gr.Image(label="Upload an image", sources=['upload', 'webcam'], type="pil"),
111
- gr.Textbox(label="The image portrays culturally-relevant information in:", placeholder="what culture does this image represent?"),
112
-
113
- gr.Dropdown(
114
- choices=["India", "Pakistan", "Bangladesh", "Afghanistan", "Bhutan", "Nepal", "Sri Lanka"],
115
- label="Country where the image was taken:",
116
- interactive=True
117
- ),
118
- gr.Textbox(label="Country where the image was taken:", placeholder="Enter country name"),
119
- gr.Radio(
 
 
 
 
 
 
 
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
- gr.Radio(
 
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 (e.g., GPT-4o, Claude, Command-R, etc.)"
136
- ),
137
- gr.Textbox(label="Caption in Native Language:", placeholder="Enter caption in the native language of the culture depicted"),
138
- gr.Textbox(label="English Caption:", placeholder="Enter caption in English")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"),