File size: 638 Bytes
a5883e4 4d1a8af a5883e4 8354893 4d1a8af 8354893 a5883e4 8354893 | 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 27 28 29 30 | import gradio as gr
from model import predict
from io import BytesIO
def predict_image(image, model_type):
"""
image: PIL Image
model_type: 'variety' or 'disease'
"""
buf = BytesIO()
image.save(buf, format="PNG")
image_bytes = buf.getvalue()
return predict(image_bytes, model_type=model_type)
gr.Interface(
fn=predict_image,
inputs=[
gr.Image(type="pil", label="Upload Banana Image"),
gr.Radio(
choices=["variety", "disease"],
value="variety",
label="Select Model"
)
],
outputs=gr.JSON(label="Prediction Result"),
).launch()
|