jillian64 commited on
Commit
5255f2b
·
verified ·
1 Parent(s): 66121a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -14,6 +14,7 @@ client = Groq(
14
  api_key=os.environ.get("GROQ_API_KEY"),
15
  )
16
 
 
17
  def clean_disease_name(name):
18
  """Clean disease name by removing numbers and special characters, and fix formatting"""
19
  # Remove numbers and dots at the beginning
@@ -409,11 +410,18 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
409
  # Store the current disease for context
410
  current_disease = gr.State("")
411
 
 
 
 
 
 
 
 
 
412
  # Main identification section
413
  with gr.Row():
414
  with gr.Column(scale=1):
415
  input_image = gr.Image(type="pil", label=text_dict["swahili"]["upload_label"])
416
- lang_btn = gr.Button(text_dict["swahili"]["lang_btn"])
417
  submit_btn = gr.Button(text_dict["swahili"]["identify_btn"], variant="primary")
418
 
419
  with gr.Column(scale=2):
@@ -442,6 +450,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
442
  # Function to switch language
443
  def switch_language(current_lang):
444
  new_lang = "english" if current_lang == "swahili" else "swahili"
 
 
 
 
445
  return (
446
  new_lang,
447
  text_dict[new_lang]["title"],
@@ -464,6 +476,9 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
464
  return None, text_dict[lang]["error_no_image"], "", ""
465
 
466
  try:
 
 
 
467
  pred_results, info, clean_disease_name = predict_and_get_info(img, lang)
468
  return pred_results, info, clean_disease_name, ""
469
  except Exception as e:
 
14
  api_key=os.environ.get("GROQ_API_KEY"),
15
  )
16
 
17
+ # Your existing functions remain the same
18
  def clean_disease_name(name):
19
  """Clean disease name by removing numbers and special characters, and fix formatting"""
20
  # Remove numbers and dots at the beginning
 
410
  # Store the current disease for context
411
  current_disease = gr.State("")
412
 
413
+ # Add prominent language switch button at the top
414
+ with gr.Row():
415
+ lang_btn = gr.Button(
416
+ text_dict["swahili"]["lang_btn"],
417
+ variant="secondary",
418
+ scale=1
419
+ )
420
+
421
  # Main identification section
422
  with gr.Row():
423
  with gr.Column(scale=1):
424
  input_image = gr.Image(type="pil", label=text_dict["swahili"]["upload_label"])
 
425
  submit_btn = gr.Button(text_dict["swahili"]["identify_btn"], variant="primary")
426
 
427
  with gr.Column(scale=2):
 
450
  # Function to switch language
451
  def switch_language(current_lang):
452
  new_lang = "english" if current_lang == "swahili" else "swahili"
453
+
454
+ # Debug message to verify the language switch is happening
455
+ print(f"Switching language from {current_lang} to {new_lang}")
456
+
457
  return (
458
  new_lang,
459
  text_dict[new_lang]["title"],
 
476
  return None, text_dict[lang]["error_no_image"], "", ""
477
 
478
  try:
479
+ # Print debug message to verify language
480
+ print(f"Processing image with language: {lang}")
481
+
482
  pred_results, info, clean_disease_name = predict_and_get_info(img, lang)
483
  return pred_results, info, clean_disease_name, ""
484
  except Exception as e: