GiGi2k5
commited on
Commit
·
c759a4d
1
Parent(s):
9294ac0
Add application file
Browse files- app.py +42 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
# Simuler une segmentation fictive de l'image
|
| 6 |
+
def segment_image(image):
|
| 7 |
+
img_array = np.array(image.resize((256, 256)))
|
| 8 |
+
segmented_img = np.zeros_like(img_array)
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
if segmented_img.ndim == 2 or segmented_img.shape[-1] == 1:
|
| 12 |
+
segmented_img = np.stack([segmented_img] * 3, axis=-1)
|
| 13 |
+
|
| 14 |
+
return Image.fromarray(segmented_img)
|
| 15 |
+
|
| 16 |
+
# Simuler un diagnostic fictif
|
| 17 |
+
def analyze_health(segmented_image):
|
| 18 |
+
# Diagnostic fictif
|
| 19 |
+
diagnostic = "La plante semble en bonne santé."
|
| 20 |
+
return diagnostic
|
| 21 |
+
|
| 22 |
+
# Fonction principale combinant segmentation fictive et diagnostic fictif
|
| 23 |
+
def plant_health_analysis(image):
|
| 24 |
+
segmented_img = segment_image(image)
|
| 25 |
+
diagnostic = analyze_health(segmented_img)
|
| 26 |
+
|
| 27 |
+
return segmented_img, diagnostic
|
| 28 |
+
|
| 29 |
+
# Interface Gradio avec la nouvelle syntaxe
|
| 30 |
+
interface = gr.Interface(
|
| 31 |
+
fn=plant_health_analysis,
|
| 32 |
+
inputs=gr.Image(type="pil", label="Téléchargez une image de plante"),
|
| 33 |
+
outputs=[
|
| 34 |
+
gr.Image(type="pil", label="Image Segmentée (Fictive)"),
|
| 35 |
+
gr.Textbox(label="Diagnostic Fictif de la Plante")
|
| 36 |
+
],
|
| 37 |
+
title="PomSafe (Fictif)",
|
| 38 |
+
description="Cette interface simule l'analyse de la santé des plantes. Le modèle de segmentation n'est pas encore intégré."
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
# Lancer l'interface Gradio
|
| 42 |
+
interface.launch(share=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
Pillow
|
| 3 |
+
numpy
|