minemaster01 commited on
Commit
ecbc96c
·
verified ·
1 Parent(s): 8021559

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -74,7 +74,7 @@ def update_state_dropdown(country):
74
  return gr.Dropdown(choices=states_by_country[country], label=f"State/Province in {country}:", interactive=True)
75
  return gr.Dropdown(choices=[], label="State/Province:", interactive=True)
76
 
77
- def process_submission(input_img, text_answer, country, state, city, se_asia_relevance, culture_knowledge, native_caption, english_caption,email):
78
  # Generate unique ID for this submission
79
  submission_id = str(uuid.uuid4())
80
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
@@ -97,7 +97,7 @@ def process_submission(input_img, text_answer, country, state, city, se_asia_rel
97
  "id": submission_id,
98
  "timestamp": timestamp,
99
  "image_filename": os.path.basename(image_path) if image_path else None,
100
- "cultural_relevance": text_answer,
101
  "country": country,
102
  "state": state,
103
  "city": city,
@@ -141,7 +141,7 @@ def process_submission(input_img, text_answer, country, state, city, se_asia_rel
141
 
142
  # Return values to display in the interface
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, "", "", ""
@@ -158,7 +158,7 @@ with gr.Blocks() as gradio_app:
158
  # Left column for image upload and basic information
159
  with gr.Column(scale=1):
160
  input_img = gr.Image(label="Upload an image", sources=['upload', 'webcam'], type="pil")
161
- text_answer = gr.Textbox(label="The image portrays culturally-relevant information in:", placeholder="what culture does this image represent?")
162
 
163
  # Location information in the left column
164
  country_dropdown = gr.Dropdown(
@@ -228,7 +228,7 @@ with gr.Blocks() as gradio_app:
228
  fn=process_submission,
229
  inputs=[
230
  input_img,
231
- text_answer,
232
  country_dropdown,
233
  state_dropdown,
234
  city_textbox,
@@ -254,7 +254,7 @@ with gr.Blocks() as gradio_app:
254
  inputs=[],
255
  outputs=[
256
  input_img,
257
- text_answer,
258
  country_dropdown,
259
  state_dropdown,
260
  city_textbox,
 
74
  return gr.Dropdown(choices=states_by_country[country], label=f"State/Province in {country}:", interactive=True)
75
  return gr.Dropdown(choices=[], label="State/Province:", interactive=True)
76
 
77
+ def process_submission(input_img, language, country, state, city, se_asia_relevance, culture_knowledge, native_caption, english_caption,email):
78
  # Generate unique ID for this submission
79
  submission_id = str(uuid.uuid4())
80
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
 
97
  "id": submission_id,
98
  "timestamp": timestamp,
99
  "image_filename": os.path.basename(image_path) if image_path else None,
100
+ "cultural_relevance": language,
101
  "country": country,
102
  "state": state,
103
  "city": city,
 
141
 
142
  # Return values to display in the interface
143
  location_info = f"Location: {city}, {state}, {country}" if state else f"Location: {city}, {country}"
144
+ return input_img, f"Your text response: {language}", 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, "", "", ""
 
158
  # Left column for image upload and basic information
159
  with gr.Column(scale=1):
160
  input_img = gr.Image(label="Upload an image", sources=['upload', 'webcam'], type="pil")
161
+ language = gr.Textbox(label="Language:", placeholder="Native Language")
162
 
163
  # Location information in the left column
164
  country_dropdown = gr.Dropdown(
 
228
  fn=process_submission,
229
  inputs=[
230
  input_img,
231
+ language,
232
  country_dropdown,
233
  state_dropdown,
234
  city_textbox,
 
254
  inputs=[],
255
  outputs=[
256
  input_img,
257
+ language,
258
  country_dropdown,
259
  state_dropdown,
260
  city_textbox,