Spaces:
Sleeping
Sleeping
import gradio as gr | |
from PIL import Image | |
def load_image(image): | |
return image | |
def analyze_image(image): | |
segmentation_result = image | |
anomaly_detection_result = image | |
disease = "Exemple de maladie de la peau" | |
advice = "Buvez suffisamment d'eau pour maintenir votre peau hydratée de l'intérieur." | |
return segmentation_result, anomaly_detection_result, disease, advice | |
def clear_analysis(): | |
return None, None, None, "", "" | |
def quitter(): | |
th = print("thanks") | |
return th | |
def aller_vers_scanner(): | |
return gr.update(visible=False), gr.update(visible=True) | |
def retour_accueil(): | |
return gr.update(visible=True), gr.update(visible=False) | |
with gr.Blocks() as demo: | |
with gr.Row(visible=True) as page_accueil: | |
with gr.Column(elem_id="centered-elements"): | |
gr.Image("logo2.png", height=200) | |
gr.Markdown("<h2 style='text-align:center;'>Bienvenue sur DermScan</h2>") | |
gr.Markdown("<h4 style='text-align:center;'>Votre application de confiance pour l'analyse et la santé de votre peau.</h4>") | |
with gr.Row(): | |
btn_quitter = gr.Button("Quitter") | |
btn_scanner = gr.Button("Scanner", elem_classes="btn") | |
with gr.Column(visible=False) as page_scanner: | |
with gr.Row() : | |
gr.Image("logo2.png", height=200) | |
gr.Markdown("<h2>Scanner votre Image</h2>") | |
with gr.Row(): | |
with gr.Column(): | |
image_input = gr.Image(type="pil", label="Charger Image") | |
btn_analyze = gr.Button("Analyser", elem_classes="btn") | |
image_output_1 = gr.Image(label="Segmentation", height=343) | |
image_output_2 = gr.Image(label="Détection d'anomalie", height=343) | |
text = gr.Textbox(label="Vous souffrez de :", placeholder="Maladie") | |
text2 = gr.TextArea(label="Quelques conseils", placeholder="Nos Conseils") | |
with gr.Row(): | |
btn_clear = gr.Button("Effacer") | |
btn_retour = gr.Button("Retour") | |
btn_quitter.click(quitter) | |
btn_scanner.click(aller_vers_scanner, None, [page_accueil, page_scanner]) | |
btn_retour.click(retour_accueil, None, [page_accueil, page_scanner]) | |
btn_analyze.click(analyze_image, inputs=image_input, outputs=[image_output_1, image_output_2, text, text2]) | |
btn_clear.click(clear_analysis, None, [image_input, image_output_1, image_output_2, text, text2]) | |
demo.launch() | |