leafbuddy / app.py
Inoue1's picture
Create app.py
e6eb87f verified
raw
history blame contribute delete
601 Bytes
import gradio as gr
from PIL import Image
from model import predict
def predict_crop(image, crop_name):
if image is None or not crop_name:
return {"error": "Image and crop_name are required"}
prediction, confidence = predict(image, crop_name)
return {
"prediction": prediction,
"confidence": confidence
}
gr.Interface(
fn=predict_crop,
inputs=[
gr.Image(type="pil"),
gr.Textbox(label="Crop Name (banana, tomato, rice)")
],
outputs="json",
api_name="/predict_crop",
title="LeafBuddy Crop Disease Detection"
).launch()