File size: 601 Bytes
e6eb87f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 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()
|