KhadijaAsehnoune12's picture
Update app.py
bffe186 verified
raw
history blame
1 kB
import gradio as gr
from PIL import Image
import numpy as np
def predict(image):
try:
# Ensure the input is a PIL Image
if isinstance(image, np.ndarray):
# Convert numpy array to PIL Image
image = Image.fromarray(image)
if not isinstance(image, Image.Image):
return {"error": "Input is not a valid image"}
# Perform your prediction here
# Placeholder for actual prediction logic
result = {"Disease": "Predicted Disease", "Confidence": 0.95}
return result
except Exception as e:
return {"error": str(e)}
interface = gr.Interface(
fn=predict,
inputs=gr.Image(type="numpy"), # Use 'numpy' type for better compatibility
outputs=gr.Label(num_top_classes=3),
examples=[["MoucheB.jpg"], ["verdissement.jpg"]],
title="Orange Disease Detector",
description="Detect diseases in orange leaves and fruits."
)
if __name__ == "__main__":
interface.launch()