Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from PIL import Image | |
| import numpy as np | |
| # Simuler une segmentation fictive de l'image | |
| 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) | |
| # Convertir en image Pillow | |
| return Image.fromarray(segmented_img) | |
| # Simuler un diagnostic fictif | |
| def analyze_health(segmented_image): | |
| diagnostic = "La plante semble en bonne santé." | |
| return diagnostic | |
| # Fonction principale combinant la segmentation fictive et le diagnostic fictif | |
| def plant_health_analysis(image): | |
| segmented_img = segment_image(image) | |
| diagnostic = analyze_health(segmented_img) | |
| return segmented_img, diagnostic | |
| # Interface Gradio | |
| 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="GreenGenius", | |
| description="Cette interface simule l'analyse de la santé des plantes. Le modèle de segmentation n'est pas encore intégré.", | |
| theme="default", | |
| layout="horizontal" | |
| ) | |
| # Lancer l'interface Gradio | |
| interface.launch(share=True) | |