File size: 2,623 Bytes
93f30c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from functions import generate_text, get_diagnosis, summarize_text, text_to_speech, translate_fr_to_es
from predict import predict
from utils import load_image
from dotenv import load_dotenv
import streamlit as st
from layout import show_header, show_prediction_section, show_footer
from styles import inject_particles_js, inject_bootstrap_and_custom_css

# Configuration de la page
st.set_page_config(
    page_title="Application Multitâche",
    page_icon=":robot_face:",
    layout="wide",
    initial_sidebar_state="auto",
)

load_dotenv()

# Injecter les styles et scripts
inject_particles_js()
inject_bootstrap_and_custom_css()

# Charger les images
image_path = "images/tumor.png"
image_base64 = load_image(image_path)
linkedin_image_base64 = load_image("images/skill-icons--linkedin.svg")
github_image_base64 = load_image("images/skill-icons--github-dark.svg")
huggingface_image_base64 = load_image("images/Hugging_Face_idJ6-I79C__1.svg")
favicon_image_base64 = load_image("images/favicon.png")

# Afficher l'en-tête
show_header(favicon_image_base64, image_base64)

# Afficher la section de prédiction
show_prediction_section()

_, col2, col3, _ = st.columns([2, 6, 6, 2])

translation = None
with col2:
    uploaded_file = st.file_uploader("Téléchargez une image de tumeur...", type=["jpg", "jpeg", "png"])
    if uploaded_file:
        _, col2, _ = st.columns([1, 3, 1])
        with col2:
            st.image(uploaded_file, caption="Image de tumeur", width=400)
            button = st.button("Prédire", use_container_width=True)
            if button:
                st.spinner("Prédiction en cours...")
                predicted, confidence = predict(uploaded_file)
                diagnosis_prompt = get_diagnosis(predicted, confidence)
                diagnosis = generate_text(diagnosis_prompt)
                summary = summarize_text(diagnosis)
                translation = translate_fr_to_es(summary)
                output_path = text_to_speech(translation)

if uploaded_file and translation:
    with col3:
        st.markdown(
            f"""
            <div class="card border-0 shadow-sm p-4">
                <div class="card-body">
                    <h2 class="gradient-text"> Resultat de la prédiction </h2>
                    <p class="lead"> {summary} </p>
                    <p class="lead"> {translation} </p
                </div>
            </div>
            """,
            unsafe_allow_html=True, 
        )

        st.audio(output_path, format="audio/mp3")

# Afficher le pied de page
show_footer(linkedin_image_base64, github_image_base64, huggingface_image_base64)