|
import gradio as gr |
|
from PIL import Image |
|
import numpy as np |
|
|
|
def predict(image): |
|
try: |
|
|
|
if isinstance(image, np.ndarray): |
|
|
|
image = Image.fromarray(image) |
|
|
|
if not isinstance(image, Image.Image): |
|
return {"error": "Input is not a valid image"} |
|
|
|
|
|
|
|
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"), |
|
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() |
|
|