Tonic commited on
Commit
b32ad38
1 Parent(s): 0f4cece

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -34
app.py CHANGED
@@ -451,24 +451,6 @@ def process_and_query(input_language=None, audio_input=None, image_input=None, t
451
  print(f"An error occurred: {e}")
452
  return "Error occurred during processing.", "No hallucination evaluation"
453
 
454
- # Interface logic
455
-
456
- def clear(components):
457
- components['language_selection'].reset()
458
- components['speech_to_text'].hide()
459
- components['image_identification'].hide()
460
- components['text_summarization'].hide()
461
- components['results'].hide()
462
-
463
- def on_language_change(language, components):
464
- if language:
465
- components['speech_to_text'].show()
466
- components['image_identification'].show()
467
- components['text_summarization'].show()
468
- else:
469
- components['speech_to_text'].hide()
470
- components['image_identification'].hide()
471
- components['text_summarization'].hide()
472
 
473
  welcome_message = """
474
  # 👋🏻Welcome to ⚕🗣️😷MultiMed - Access Chat ⚕🗣️😷
@@ -591,10 +573,37 @@ languages = [
591
  "Standard Malay",
592
  "Zulu"
593
  ]
594
- with gr.Blocks(theme='ParityError/Anime') as iface:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
595
 
 
 
596
  with gr.Row() as language_selection:
597
- input_language = gr.Dropdown(languages, label="Select the language", value="English", interactive=True)
598
  components['language_selection'] = language_selection
599
 
600
  with gr.Accordion("Speech to Text", open=False) as speech_to_text:
@@ -620,9 +629,9 @@ with gr.Blocks(theme='ParityError/Anime') as iface:
620
  components['results'] = results
621
 
622
  clear_button = gr.Button("Clear")
623
- clear_button.click(clear, inputs=[components], outputs=[])
624
 
625
- text_button.click(process_and_query, inputs=[input_language, audio_input, image_input, text_input, components], outputs=[text_output, hallucination_output])
626
 
627
  # Initially hide all blocks except language selection
628
  components['speech_to_text'].hide()
@@ -630,15 +639,4 @@ components['image_identification'].hide()
630
  components['text_summarization'].hide()
631
  components['results'].hide()
632
 
633
- gr.Examples([
634
- ["What is the proper treatment for buccal herpes?"],
635
- ["Male, 40 presenting with swollen glands and a rash"],
636
- ["How does cellular metabolism work TCA cycle"],
637
- ["What special care must be provided to children with chicken pox?"],
638
- ["When and how often should I wash my hands?"],
639
- ["بکل ہرپس کا صحیح علاج کیا ہے؟"],
640
- ["구강 헤르페스의 적절한 치료법은 무엇입니까?"],
641
- ["Je, ni matibabu gani sahihi kwa herpes ya buccal?"],
642
- ],inputs=[text_input])
643
-
644
- iface.queue().launch(show_error=True,debug=True)
 
451
  print(f"An error occurred: {e}")
452
  return "Error occurred during processing.", "No hallucination evaluation"
453
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
454
 
455
  welcome_message = """
456
  # 👋🏻Welcome to ⚕🗣️😷MultiMed - Access Chat ⚕🗣️😷
 
573
  "Standard Malay",
574
  "Zulu"
575
  ]
576
+ def process_and_query(input_language, audio_input, image_input, text_input):
577
+ # Your processing logic here
578
+ # Hide input components and show result components after processing
579
+ components['speech_to_text'].hide()
580
+ components['image_identification'].hide()
581
+ components['text_summarization'].hide()
582
+ components['results'].show()
583
+ # Return the processed text and hallucination evaluation
584
+ return "Processed Text in " + input_language, "Hallucination Evaluation"
585
+
586
+ def clear():
587
+ components['language_selection'].reset()
588
+ components['speech_to_text'].hide()
589
+ components['image_identification'].hide()
590
+ components['text_summarization'].hide()
591
+ components['results'].hide()
592
+
593
+ def on_language_change(language):
594
+ if language:
595
+ components['speech_to_text'].show()
596
+ components['image_identification'].show()
597
+ components['text_summarization'].show()
598
+ else:
599
+ components['speech_to_text'].hide()
600
+ components['image_identification'].hide()
601
+ components['text_summarization'].hide()
602
 
603
+
604
+ with gr.Blocks(theme='ParityError/Anime') as iface:
605
  with gr.Row() as language_selection:
606
+ input_language = gr.Dropdown(languages, label="Select the language", value="English", interactive=True, change=lambda x: on_language_change(x))
607
  components['language_selection'] = language_selection
608
 
609
  with gr.Accordion("Speech to Text", open=False) as speech_to_text:
 
629
  components['results'] = results
630
 
631
  clear_button = gr.Button("Clear")
632
+ clear_button.click(clear, inputs=[], outputs=[])
633
 
634
+ text_button.click(process_and_query, inputs=[input_language, audio_input, image_input, text_input], outputs=[text_output, hallucination_output])
635
 
636
  # Initially hide all blocks except language selection
637
  components['speech_to_text'].hide()
 
639
  components['text_summarization'].hide()
640
  components['results'].hide()
641
 
642
+ iface.launch(show_error=True, debug=True)