Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
| 1 |
-
# Welcome to Team Tonic's MultiMed
|
| 2 |
-
|
| 3 |
from gradio_client import Client
|
| 4 |
import numpy as np
|
| 5 |
import gradio as gr
|
|
@@ -17,6 +15,63 @@ import os
|
|
| 17 |
import uuid
|
| 18 |
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
# Global variables to hold component references
|
| 21 |
components = {}
|
| 22 |
dotenv.load_dotenv()
|
|
@@ -176,7 +231,7 @@ def convert_text_to_speech(input_text: str, source_language: str, target_languag
|
|
| 176 |
return audio_file_path, translated_text
|
| 177 |
|
| 178 |
except Exception as e:
|
| 179 |
-
return f"Error in text-to-speech conversion: {str(e)}"
|
| 180 |
|
| 181 |
|
| 182 |
def process_image(image_input):
|
|
@@ -379,7 +434,6 @@ def process_and_query(input_language=None, audio_input=None, image_input=None, t
|
|
| 379 |
combined_text = ""
|
| 380 |
markdown_output = ""
|
| 381 |
image_text = ""
|
| 382 |
-
# Initialize language code
|
| 383 |
language_code = None
|
| 384 |
|
| 385 |
# Convert input language to its code
|
|
@@ -434,7 +488,7 @@ def process_and_query(input_language=None, audio_input=None, image_input=None, t
|
|
| 434 |
final_response = process_summary_with_stablemed(summary)
|
| 435 |
|
| 436 |
# Convert translated text to speech and get both audio file and text
|
| 437 |
-
target_language = "
|
| 438 |
audio_output, translated_text = convert_text_to_speech(final_response, target_language, language_code)
|
| 439 |
|
| 440 |
# Evaluate hallucination
|
|
@@ -454,63 +508,6 @@ def process_and_query(input_language=None, audio_input=None, image_input=None, t
|
|
| 454 |
return f"Error occurred during processing: {e}. No hallucination evaluation.", None
|
| 455 |
|
| 456 |
|
| 457 |
-
welcome_message = """
|
| 458 |
-
# 👋🏻Welcome to ⚕🗣️😷MultiMed - Access Chat ⚕🗣️😷
|
| 459 |
-
|
| 460 |
-
🗣️📝 This is an educational and accessible conversational tool.
|
| 461 |
-
|
| 462 |
-
### How To Use ⚕🗣️😷MultiMed⚕:
|
| 463 |
-
|
| 464 |
-
🗣️📝Interact with ⚕🗣️😷MultiMed⚕ in any language using image, audio or text!
|
| 465 |
-
|
| 466 |
-
📚🌟💼 that uses [Tonic/stablemed](https://huggingface.co/Tonic/stablemed) and [adept/fuyu-8B](https://huggingface.co/adept/fuyu-8b) with [Vectara](https://huggingface.co/vectara) embeddings + retrieval.
|
| 467 |
-
do [get in touch](https://discord.gg/GWpVpekp). You can also use 😷MultiMed⚕️ on your own data & in your own way by cloning this space. 🧬🔬🔍 Simply click here: <a style="display:inline-block" href="https://huggingface.co/spaces/TeamTonic/MultiMed?duplicate=true"><img src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a></h3>
|
| 468 |
-
### Join us :
|
| 469 |
-
|
| 470 |
-
🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community on 👻Discord: [Discord](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Polytonic](https://github.com/tonic-ai) & contribute to 🌟 [PolyGPT](https://github.com/tonic-ai/polygpt-alpha)"
|
| 471 |
-
"""
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
languages = {
|
| 475 |
-
"English": "eng",
|
| 476 |
-
"Modern Standard Arabic": "arb",
|
| 477 |
-
"Bengali": "ben",
|
| 478 |
-
"Catalan": "cat",
|
| 479 |
-
"Czech": "ces",
|
| 480 |
-
"Mandarin Chinese": "cmn",
|
| 481 |
-
"Welsh": "cym",
|
| 482 |
-
"Danish": "dan",
|
| 483 |
-
"German": "deu",
|
| 484 |
-
"Estonian": "est",
|
| 485 |
-
"Finnish": "fin",
|
| 486 |
-
"French": "fra",
|
| 487 |
-
"Hindi": "hin",
|
| 488 |
-
"Indonesian": "ind",
|
| 489 |
-
"Italian": "ita",
|
| 490 |
-
"Japanese": "jpn",
|
| 491 |
-
"Korean": "kor",
|
| 492 |
-
"Maltese": "mlt",
|
| 493 |
-
"Dutch": "nld",
|
| 494 |
-
"Western Persian": "pes",
|
| 495 |
-
"Polish": "pol",
|
| 496 |
-
"Portuguese": "por",
|
| 497 |
-
"Romanian": "ron",
|
| 498 |
-
"Russian": "rus",
|
| 499 |
-
"Slovak": "slk",
|
| 500 |
-
"Spanish": "spa",
|
| 501 |
-
"Swedish": "swe",
|
| 502 |
-
"Swahili": "swh",
|
| 503 |
-
"Telugu": "tel",
|
| 504 |
-
"Tagalog": "tgl",
|
| 505 |
-
"Thai": "tha",
|
| 506 |
-
"Turkish": "tur",
|
| 507 |
-
"Ukrainian": "ukr",
|
| 508 |
-
"Urdu": "urd",
|
| 509 |
-
"Northern Uzbek": "uzn",
|
| 510 |
-
"Vietnamese": "vie"
|
| 511 |
-
}
|
| 512 |
-
|
| 513 |
-
|
| 514 |
def clear():
|
| 515 |
# Return default values for each component
|
| 516 |
return "English", None, None, "", None
|
|
|
|
|
|
|
|
|
|
| 1 |
from gradio_client import Client
|
| 2 |
import numpy as np
|
| 3 |
import gradio as gr
|
|
|
|
| 15 |
import uuid
|
| 16 |
|
| 17 |
|
| 18 |
+
welcome_message = """
|
| 19 |
+
# 👋🏻Welcome to ⚕🗣️😷MultiMed - Access Chat ⚕🗣️😷
|
| 20 |
+
|
| 21 |
+
🗣️📝 This is an educational and accessible conversational tool.
|
| 22 |
+
|
| 23 |
+
### How To Use ⚕🗣️😷MultiMed⚕:
|
| 24 |
+
|
| 25 |
+
🗣️📝Interact with ⚕🗣️😷MultiMed⚕ in any language using image, audio or text!
|
| 26 |
+
|
| 27 |
+
📚🌟💼 that uses [Tonic/stablemed](https://huggingface.co/Tonic/stablemed) and [adept/fuyu-8B](https://huggingface.co/adept/fuyu-8b) with [Vectara](https://huggingface.co/vectara) embeddings + retrieval.
|
| 28 |
+
do [get in touch](https://discord.gg/GWpVpekp). You can also use 😷MultiMed⚕️ on your own data & in your own way by cloning this space. 🧬🔬🔍 Simply click here: <a style="display:inline-block" href="https://huggingface.co/spaces/TeamTonic/MultiMed?duplicate=true"><img src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a></h3>
|
| 29 |
+
### Join us :
|
| 30 |
+
|
| 31 |
+
🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community on 👻Discord: [Discord](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Polytonic](https://github.com/tonic-ai) & contribute to 🌟 [PolyGPT](https://github.com/tonic-ai/polygpt-alpha)"
|
| 32 |
+
"""
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
languages = {
|
| 36 |
+
"English": "eng",
|
| 37 |
+
"Modern Standard Arabic": "arb",
|
| 38 |
+
"Bengali": "ben",
|
| 39 |
+
"Catalan": "cat",
|
| 40 |
+
"Czech": "ces",
|
| 41 |
+
"Mandarin Chinese": "cmn",
|
| 42 |
+
"Welsh": "cym",
|
| 43 |
+
"Danish": "dan",
|
| 44 |
+
"German": "deu",
|
| 45 |
+
"Estonian": "est",
|
| 46 |
+
"Finnish": "fin",
|
| 47 |
+
"French": "fra",
|
| 48 |
+
"Hindi": "hin",
|
| 49 |
+
"Indonesian": "ind",
|
| 50 |
+
"Italian": "ita",
|
| 51 |
+
"Japanese": "jpn",
|
| 52 |
+
"Korean": "kor",
|
| 53 |
+
"Maltese": "mlt",
|
| 54 |
+
"Dutch": "nld",
|
| 55 |
+
"Western Persian": "pes",
|
| 56 |
+
"Polish": "pol",
|
| 57 |
+
"Portuguese": "por",
|
| 58 |
+
"Romanian": "ron",
|
| 59 |
+
"Russian": "rus",
|
| 60 |
+
"Slovak": "slk",
|
| 61 |
+
"Spanish": "spa",
|
| 62 |
+
"Swedish": "swe",
|
| 63 |
+
"Swahili": "swh",
|
| 64 |
+
"Telugu": "tel",
|
| 65 |
+
"Tagalog": "tgl",
|
| 66 |
+
"Thai": "tha",
|
| 67 |
+
"Turkish": "tur",
|
| 68 |
+
"Ukrainian": "ukr",
|
| 69 |
+
"Urdu": "urd",
|
| 70 |
+
"Northern Uzbek": "uzn",
|
| 71 |
+
"Vietnamese": "vie"
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
|
| 75 |
# Global variables to hold component references
|
| 76 |
components = {}
|
| 77 |
dotenv.load_dotenv()
|
|
|
|
| 231 |
return audio_file_path, translated_text
|
| 232 |
|
| 233 |
except Exception as e:
|
| 234 |
+
return None, f"Error in text-to-speech conversion: {str(e)}"
|
| 235 |
|
| 236 |
|
| 237 |
def process_image(image_input):
|
|
|
|
| 434 |
combined_text = ""
|
| 435 |
markdown_output = ""
|
| 436 |
image_text = ""
|
|
|
|
| 437 |
language_code = None
|
| 438 |
|
| 439 |
# Convert input language to its code
|
|
|
|
| 488 |
final_response = process_summary_with_stablemed(summary)
|
| 489 |
|
| 490 |
# Convert translated text to speech and get both audio file and text
|
| 491 |
+
target_language = "eng" # Set the target language for the speech
|
| 492 |
audio_output, translated_text = convert_text_to_speech(final_response, target_language, language_code)
|
| 493 |
|
| 494 |
# Evaluate hallucination
|
|
|
|
| 508 |
return f"Error occurred during processing: {e}. No hallucination evaluation.", None
|
| 509 |
|
| 510 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 511 |
def clear():
|
| 512 |
# Return default values for each component
|
| 513 |
return "English", None, None, "", None
|