|
|
import gradio as gr |
|
|
import tensorflow as tf |
|
|
import numpy as np |
|
|
import cv2 |
|
|
|
|
|
|
|
|
model = tf.keras.models.load_model("mon_modele.h5") |
|
|
|
|
|
|
|
|
classes = ["Sain", "Mildiou", "Rouille", "Oïdium"] |
|
|
|
|
|
|
|
|
def predict_image(image): |
|
|
|
|
|
img = cv2.resize(image, (224, 224)) |
|
|
img = img / 255.0 |
|
|
img = np.expand_dims(img, axis=0) |
|
|
|
|
|
|
|
|
prediction = model.predict(img) |
|
|
predicted_class = np.argmax(prediction) |
|
|
return f"Résultat : {classes[predicted_class]}" |
|
|
|
|
|
|
|
|
interface = gr.Interface( |
|
|
fn=predict_image, |
|
|
inputs=gr.Image(type="numpy"), |
|
|
outputs="text", |
|
|
title="Détection des Maladies des Plantes 🌿", |
|
|
description="Télécharge une image d'une feuille de plante pour obtenir une analyse IA." |
|
|
) |
|
|
|
|
|
|
|
|
interface.launch() |
|
|
|