Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -396,6 +396,10 @@ def process_summary_with_stablemed(summary):
|
|
396 |
# Main function to handle the Gradio interface logic
|
397 |
|
398 |
def process_and_query(input_language=None, audio_input=None, image_input=None, text_input=None):
|
|
|
|
|
|
|
|
|
399 |
try:
|
400 |
# Initialize the conditional variables
|
401 |
combined_text = ""
|
@@ -448,23 +452,22 @@ def process_and_query(input_language=None, audio_input=None, image_input=None, t
|
|
448 |
|
449 |
# Interface logic
|
450 |
|
451 |
-
def clear(
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
|
458 |
-
|
459 |
-
def on_language_change(language, interface):
|
460 |
if language:
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
else:
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
|
469 |
welcome_message = """
|
470 |
# 👋🏻Welcome to ⚕🗣️😷MultiMed - Access Chat ⚕🗣️😷
|
@@ -587,39 +590,45 @@ languages = [
|
|
587 |
"Standard Malay",
|
588 |
"Zulu"
|
589 |
]
|
590 |
-
|
591 |
-
|
592 |
with gr.Blocks(theme='ParityError/Anime') as iface:
|
|
|
|
|
593 |
with gr.Row() as language_selection:
|
594 |
input_language = gr.Dropdown(languages, label="Select the language", value="English", interactive=True)
|
|
|
595 |
|
596 |
with gr.Accordion("Speech to Text", open=False) as speech_to_text:
|
597 |
audio_input = gr.Audio(label="Speak", type="filepath", sources="microphone")
|
598 |
audio_output = gr.Markdown(label="Output text")
|
|
|
599 |
|
600 |
with gr.Accordion("Image Identification", open=False) as image_identification:
|
601 |
image_input = gr.Image(label="Upload image")
|
602 |
image_output = gr.Markdown(label="Output text")
|
|
|
603 |
|
604 |
with gr.Accordion("Text Summarization", open=False) as text_summarization:
|
605 |
text_input = gr.Textbox(label="Input text", lines=5)
|
606 |
text_output = gr.Markdown(label="Output text")
|
607 |
text_button = gr.Button("Process text")
|
608 |
hallucination_output = gr.Label(label="Hallucination Evaluation")
|
609 |
-
|
610 |
|
611 |
with gr.Row() as results:
|
612 |
text_output = gr.Markdown()
|
613 |
hallucination_output = gr.Label()
|
|
|
614 |
|
615 |
clear_button = gr.Button("Clear")
|
616 |
-
clear_button.click(clear, inputs=[
|
|
|
|
|
617 |
|
618 |
# Initially hide all blocks except language selection
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
|
624 |
gr.Examples([
|
625 |
["What is the proper treatment for buccal herpes?"],
|
|
|
396 |
# Main function to handle the Gradio interface logic
|
397 |
|
398 |
def process_and_query(input_language=None, audio_input=None, image_input=None, text_input=None):
|
399 |
+
components['speech_to_text'].hide()
|
400 |
+
components['image_identification'].hide()
|
401 |
+
components['text_summarization'].hide()
|
402 |
+
components['results'].show()
|
403 |
try:
|
404 |
# Initialize the conditional variables
|
405 |
combined_text = ""
|
|
|
452 |
|
453 |
# Interface logic
|
454 |
|
455 |
+
def clear(components):
|
456 |
+
components['language_selection'].reset()
|
457 |
+
components['speech_to_text'].hide()
|
458 |
+
components['image_identification'].hide()
|
459 |
+
components['text_summarization'].hide()
|
460 |
+
components['results'].hide()
|
461 |
|
462 |
+
def on_language_change(language, components):
|
|
|
463 |
if language:
|
464 |
+
components['speech_to_text'].show()
|
465 |
+
components['image_identification'].show()
|
466 |
+
components['text_summarization'].show()
|
467 |
else:
|
468 |
+
components['speech_to_text'].hide()
|
469 |
+
components['image_identification'].hide()
|
470 |
+
components['text_summarization'].hide()
|
471 |
|
472 |
welcome_message = """
|
473 |
# 👋🏻Welcome to ⚕🗣️😷MultiMed - Access Chat ⚕🗣️😷
|
|
|
590 |
"Standard Malay",
|
591 |
"Zulu"
|
592 |
]
|
|
|
|
|
593 |
with gr.Blocks(theme='ParityError/Anime') as iface:
|
594 |
+
components = {}
|
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:
|
601 |
audio_input = gr.Audio(label="Speak", type="filepath", sources="microphone")
|
602 |
audio_output = gr.Markdown(label="Output text")
|
603 |
+
components['speech_to_text'] = speech_to_text
|
604 |
|
605 |
with gr.Accordion("Image Identification", open=False) as image_identification:
|
606 |
image_input = gr.Image(label="Upload image")
|
607 |
image_output = gr.Markdown(label="Output text")
|
608 |
+
components['image_identification'] = image_identification
|
609 |
|
610 |
with gr.Accordion("Text Summarization", open=False) as text_summarization:
|
611 |
text_input = gr.Textbox(label="Input text", lines=5)
|
612 |
text_output = gr.Markdown(label="Output text")
|
613 |
text_button = gr.Button("Process text")
|
614 |
hallucination_output = gr.Label(label="Hallucination Evaluation")
|
615 |
+
components['text_summarization'] = text_summarization
|
616 |
|
617 |
with gr.Row() as results:
|
618 |
text_output = gr.Markdown()
|
619 |
hallucination_output = gr.Label()
|
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()
|
629 |
+
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?"],
|