|
|
import gradio as gr |
|
|
from PIL import Image |
|
|
import numpy as np |
|
|
|
|
|
|
|
|
def segment_image(image): |
|
|
img_array = np.array(image.resize((256, 256))) |
|
|
segmented_img = np.zeros_like(img_array) |
|
|
|
|
|
|
|
|
if segmented_img.ndim == 2 or segmented_img.shape[-1] == 1: |
|
|
segmented_img = np.stack([segmented_img] * 3, axis=-1) |
|
|
|
|
|
return Image.fromarray(segmented_img) |
|
|
|
|
|
|
|
|
def analyze_health(segmented_image): |
|
|
|
|
|
diagnostic = "La plante semble en bonne santé." |
|
|
return diagnostic |
|
|
|
|
|
|
|
|
def plant_health_analysis(image): |
|
|
segmented_img = segment_image(image) |
|
|
diagnostic = analyze_health(segmented_img) |
|
|
|
|
|
return segmented_img, diagnostic |
|
|
|
|
|
|
|
|
interface = gr.Interface( |
|
|
fn=plant_health_analysis, |
|
|
inputs=gr.Image(type="pil", label="Téléchargez une image de plante"), |
|
|
outputs=[ |
|
|
gr.Image(type="pil", label="Image Segmentée (Fictive)"), |
|
|
gr.Textbox(label="Diagnostic Fictif de la Plante") |
|
|
], |
|
|
title="PomSafe (Fictif)", |
|
|
description="Cette interface simule l'analyse de la santé des plantes. Le modèle de segmentation n'est pas encore intégré." |
|
|
) |
|
|
|
|
|
|
|
|
interface.launch(share=True) |
|
|
|