Skym616 commited on
Commit
0bd25ee
·
1 Parent(s): a91f341
__pycache__/functions.cpython-310.pyc CHANGED
Binary files a/__pycache__/functions.cpython-310.pyc and b/__pycache__/functions.cpython-310.pyc differ
 
app.py CHANGED
@@ -45,28 +45,46 @@ with col2:
45
  st.image(uploaded_file, caption="Image de tumeur", width=400)
46
  button = st.button("Prédire", use_container_width=True)
47
  if button:
48
- st.spinner("Prédiction en cours...")
49
  predicted, confidence = predict(uploaded_file)
50
  diagnosis_prompt = get_diagnosis(predicted, confidence)
51
  diagnosis = generate_text(diagnosis_prompt)
52
  summary = summarize_text(diagnosis)
53
  translation = translate_fr_to_es(summary)
54
- output_path = text_to_speech(translation)
55
 
56
  if uploaded_file and translation:
57
  with col3:
58
  st.markdown(
59
  f"""
60
- <div class="card border-0 shadow-sm p-4">
61
  <div class="card-body">
62
  <h2 class="gradient-text"> Resultat de la prédiction </h2>
63
  <p class="lead"> {summary} </p>
64
  </div>
 
 
 
 
 
 
65
  </div>
66
  """,
67
  unsafe_allow_html=True,
68
  )
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  st.audio(output_path, format="audio/mp3")
71
 
72
  # Afficher le pied de page
 
45
  st.image(uploaded_file, caption="Image de tumeur", width=400)
46
  button = st.button("Prédire", use_container_width=True)
47
  if button:
 
48
  predicted, confidence = predict(uploaded_file)
49
  diagnosis_prompt = get_diagnosis(predicted, confidence)
50
  diagnosis = generate_text(diagnosis_prompt)
51
  summary = summarize_text(diagnosis)
52
  translation = translate_fr_to_es(summary)
53
+ output_path = text_to_speech(summary)
54
 
55
  if uploaded_file and translation:
56
  with col3:
57
  st.markdown(
58
  f"""
59
+ <div class="container card border-0 shadow-sm p-4 mt-2">
60
  <div class="card-body">
61
  <h2 class="gradient-text"> Resultat de la prédiction </h2>
62
  <p class="lead"> {summary} </p>
63
  </div>
64
+ </div>
65
+ <div class="container card border-0 shadow-sm p-4 mt-2">
66
+ <div class="card-body">
67
+ <h2 class="gradient-text"> Traduction en espagnol </h2>
68
+ <p class="lead"> {translation} </p>
69
+ </div>
70
  </div>
71
  """,
72
  unsafe_allow_html=True,
73
  )
74
 
75
+ st.markdown(
76
+ f"""
77
+ <div class="container card border-0 shadow-sm p-4">
78
+ <div class="card-body">
79
+ <h2 class="gradient-text"> Plus de détail </h2>
80
+ <p class="lead"> {diagnosis} </p>
81
+ </div>
82
+ </div>
83
+ """,
84
+ unsafe_allow_html=True,
85
+ )
86
+ _, col2, _ = st.columns([2, 3, 2])
87
+ with col2:
88
  st.audio(output_path, format="audio/mp3")
89
 
90
  # Afficher le pied de page
functions.py CHANGED
@@ -23,7 +23,7 @@ def summarize_text(text):
23
  def get_diagnosis(prediction, confidence):
24
  labels = ["glioma", "meningioma", "notumor", "pituitary"]
25
  result = labels[prediction]
26
- prompt = f'Tu es un médecin qui doit annoncer à un patient le type de tumeur qu\'il a. Le type de tumeur prédit est "{result}" avec une confiance de {confidence}. Veuillez fournir un diagnostic concis, précis et des conseils.'
27
  return prompt
28
 
29
 
@@ -67,6 +67,6 @@ def translate_fr_to_es(input_text, max_retries=5):
67
  # Audio to text model
68
  def text_to_speech(input_text):
69
  outputh_path = "text_to_speech.mp3"
70
- tts = gTTS(text=input_text, lang="es")
71
  tts.save(outputh_path)
72
  return outputh_path
 
23
  def get_diagnosis(prediction, confidence):
24
  labels = ["glioma", "meningioma", "notumor", "pituitary"]
25
  result = labels[prediction]
26
+ prompt = f'Tu es un médecin qui s\'appelle Skym qui doit annoncer à un patient X le type de tumeur qu\'il a. Le type de tumeur prédit est "{result}" avec une confiance de {confidence}. Veuillez fournir un diagnostic concis, précis et des conseils.'
27
  return prompt
28
 
29
 
 
67
  # Audio to text model
68
  def text_to_speech(input_text):
69
  outputh_path = "text_to_speech.mp3"
70
+ tts = gTTS(text=input_text, lang="fr")
71
  tts.save(outputh_path)
72
  return outputh_path
text_to_speech.mp3 CHANGED
Binary files a/text_to_speech.mp3 and b/text_to_speech.mp3 differ