Spaces:
Running
Running
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: | |
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> | |
</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) |