minemaster01 commited on
Commit
d68a5db
·
verified ·
1 Parent(s): d615edd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -85,7 +85,7 @@ def update_other_language_visibility(selected_language):
85
  return gr.update(visible=(selected_language == "OTHER"))
86
 
87
  def process_submission(input_img, language, country, state, city, se_asia_relevance, culture_knowledge,
88
- native_caption, english_caption, code_mixed_caption, domain, email, other_language, other_country, other_state):
89
  """Validates, saves, and uploads a user submission."""
90
  warnings = {
91
  "img": (not input_img, "<span style='color:red'>⚠️ Please upload an image.</span>"),
@@ -95,7 +95,7 @@ def process_submission(input_img, language, country, state, city, se_asia_releva
95
  "relevance": (not se_asia_relevance, "<span style='color:red'>⚠️ Please select the cultural relevance.</span>"),
96
  "knowledge": (not culture_knowledge, "<span style='color:red'>⚠️ Please select your knowledge source.</span>"),
97
  "english": (not english_caption, "<span style='color:red'>⚠️ Please enter an English caption.</span>"),
98
- "code_mixed": (not code_mixed_caption, "<span style='color:red'>⚠️ Please enter a code-mixed caption.</span>"),
99
  }
100
  if any(v[0] for v in warnings.values()):
101
  return (
@@ -108,7 +108,7 @@ def process_submission(input_img, language, country, state, city, se_asia_releva
108
  gr.update(visible=True, value=warnings["knowledge"][1] if warnings["knowledge"][0] else ""),
109
  gr.update(visible=False),
110
  gr.update(visible=True, value=warnings["english"][1] if warnings["english"][0] else ""),
111
- gr.update(visible=True, value=warnings["code_mixed"][1] if warnings["code_mixed"][0] else ""),
112
  gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
113
  gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
114
  gr.update(visible=False), gr.update(visible=False)
@@ -127,7 +127,7 @@ def process_submission(input_img, language, country, state, city, se_asia_releva
127
  "language": final_language, "country": final_country, "state": final_state, "city": city,
128
  "se_asia_relevance": se_asia_relevance, "cultural_knowledge_source": culture_knowledge,
129
  "native_caption": native_caption, "english_caption": english_caption,
130
- "code_mixed_caption": code_mixed_caption, "domain": domain, "email": email,
131
  }
132
  json_filename = f"{timestamp}.json"
133
  json_path = os.path.join("submissions", json_filename)
@@ -207,8 +207,8 @@ with gr.Blocks(theme='1024m/1024m-1') as gradio_app:
207
  native_warning = gr.Markdown(visible=False)
208
  english_caption = gr.Textbox(label="English Caption:", placeholder="Enter caption in English (script only)")
209
  english_warning = gr.Markdown(visible=False)
210
- code_mixed_caption = gr.Textbox(label="Code-Mixed Caption:", placeholder="Enter caption in code-mixed (English script only)")
211
- code_mixed_warning = gr.Markdown(visible=False)
212
  domain = gr.Textbox(label="Domain (Optional but preferred):", placeholder="1-2 word description")
213
 
214
  with gr.Row():
@@ -241,12 +241,12 @@ with gr.Blocks(theme='1024m/1024m-1') as gradio_app:
241
  inputs=[
242
  input_img, language, country_dropdown, state_dropdown, city_textbox,
243
  se_asia_relevance, culture_knowledge, native_caption, english_caption,
244
- code_mixed_caption, domain, email_input, other_language, other_country,
245
  other_state_textbox
246
  ],
247
  outputs=[
248
  img_warning, lang_warning, country_warning, city_warning, email_warning,
249
- relevance_warning, knowledge_warning, native_warning, english_warning, code_mixed_warning,
250
  output_img, output_text, output_location,
251
  output_relevance, output_knowledge, output_native, output_english, output_domain
252
  ]
@@ -255,9 +255,9 @@ with gr.Blocks(theme='1024m/1024m-1') as gradio_app:
255
  components_to_clear = [
256
  input_img, language, other_language, country_dropdown, other_country, state_dropdown,
257
  other_state_textbox, city_textbox, se_asia_relevance, culture_knowledge, native_caption,
258
- english_caption, code_mixed_caption, domain, email_input,
259
  img_warning, lang_warning, country_warning, city_warning, email_warning, relevance_warning,
260
- knowledge_warning, native_warning, english_warning, code_mixed_warning,
261
  output_img, output_text,
262
  output_location, output_relevance, output_knowledge, output_native, output_english, output_domain
263
  ]
 
85
  return gr.update(visible=(selected_language == "OTHER"))
86
 
87
  def process_submission(input_img, language, country, state, city, se_asia_relevance, culture_knowledge,
88
+ native_caption, english_caption, transliterated_caption, domain, email, other_language, other_country, other_state):
89
  """Validates, saves, and uploads a user submission."""
90
  warnings = {
91
  "img": (not input_img, "<span style='color:red'>⚠️ Please upload an image.</span>"),
 
95
  "relevance": (not se_asia_relevance, "<span style='color:red'>⚠️ Please select the cultural relevance.</span>"),
96
  "knowledge": (not culture_knowledge, "<span style='color:red'>⚠️ Please select your knowledge source.</span>"),
97
  "english": (not english_caption, "<span style='color:red'>⚠️ Please enter an English caption.</span>"),
98
+ "transliterated": (not transliterated_caption, "<span style='color:red'>⚠️ Please enter a transliterated caption.</span>"),
99
  }
100
  if any(v[0] for v in warnings.values()):
101
  return (
 
108
  gr.update(visible=True, value=warnings["knowledge"][1] if warnings["knowledge"][0] else ""),
109
  gr.update(visible=False),
110
  gr.update(visible=True, value=warnings["english"][1] if warnings["english"][0] else ""),
111
+ gr.update(visible=True, value=warnings["transliterated"][1] if warnings["transliterated"][0] else ""),
112
  gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
113
  gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
114
  gr.update(visible=False), gr.update(visible=False)
 
127
  "language": final_language, "country": final_country, "state": final_state, "city": city,
128
  "se_asia_relevance": se_asia_relevance, "cultural_knowledge_source": culture_knowledge,
129
  "native_caption": native_caption, "english_caption": english_caption,
130
+ "transliterated_caption": transliterated_caption, "domain": domain, "email": email,
131
  }
132
  json_filename = f"{timestamp}.json"
133
  json_path = os.path.join("submissions", json_filename)
 
207
  native_warning = gr.Markdown(visible=False)
208
  english_caption = gr.Textbox(label="English Caption:", placeholder="Enter caption in English (script only)")
209
  english_warning = gr.Markdown(visible=False)
210
+ transliterated_caption = gr.Textbox(label="Transliterated Caption:", placeholder="Enter caption in transliterated (English script only)")
211
+ transliterated_warning = gr.Markdown(visible=False)
212
  domain = gr.Textbox(label="Domain (Optional but preferred):", placeholder="1-2 word description")
213
 
214
  with gr.Row():
 
241
  inputs=[
242
  input_img, language, country_dropdown, state_dropdown, city_textbox,
243
  se_asia_relevance, culture_knowledge, native_caption, english_caption,
244
+ transliterated_caption, domain, email_input, other_language, other_country,
245
  other_state_textbox
246
  ],
247
  outputs=[
248
  img_warning, lang_warning, country_warning, city_warning, email_warning,
249
+ relevance_warning, knowledge_warning, native_warning, english_warning, transliterated_warning,
250
  output_img, output_text, output_location,
251
  output_relevance, output_knowledge, output_native, output_english, output_domain
252
  ]
 
255
  components_to_clear = [
256
  input_img, language, other_language, country_dropdown, other_country, state_dropdown,
257
  other_state_textbox, city_textbox, se_asia_relevance, culture_knowledge, native_caption,
258
+ english_caption, transliterated_caption, domain, email_input,
259
  img_warning, lang_warning, country_warning, city_warning, email_warning, relevance_warning,
260
+ knowledge_warning, native_warning, english_warning, transliterated_warning,
261
  output_img, output_text,
262
  output_location, output_relevance, output_knowledge, output_native, output_english, output_domain
263
  ]