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=":brain:", 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: predicted, confidence = predict(uploaded_file) diagnosis_prompt, label = get_diagnosis(predicted, confidence) diagnosis = generate_text(diagnosis_prompt) summary = summarize_text(diagnosis) translation = translate_fr_to_es(summary) output_path = text_to_speech(summary) if uploaded_file and translation: with col3: st.markdown( f"""

Resultat de la prédiction

Type de tumeur: {label}

{summary}

Traduction en espagnol

{translation}

""", unsafe_allow_html=True, ) st.audio(output_path, format="audio/mp3") st.markdown( f"""

Plus de détail

{diagnosis}

""", unsafe_allow_html=True, ) # Afficher le pied de page show_footer(linkedin_image_base64, github_image_base64, huggingface_image_base64)