Spaces:
Sleeping
Sleeping
Commit ·
7d764e2
1
Parent(s): 3e6ffb6
Fix: ensure image is PIL.Image for Hugging Face pipeline
Browse files12345678910import gradio as grfrom transformers import pipelinemodel = pipeline("image-classification", model="wellCh4n/tomato-leaf-disease-classification-vit")def classify(image):result = model(image)return resultgr.Interface(fn=classify, inputs="image", outputs="label").launch()1234567891011121314151617181920import gradio as grfrom transformers import pipelinefrom PIL import Image # ✅ make sure PIL is imported# Load your modelmodel = pipeline("image-classification", model="wellCh4n/tomato-leaf-disease-classification-vit")def classify(image):if not isinstance(image, Image.Image):image = Image.fromarray(image) # fallback, just in caseresult = model(image)return result[0]['label'] # return top labelgr.Interface(fn=classify,inputs=gr.Image(type="pil"),outputs="label",title="Tomato Leaf Disease Analyzer",description="Upload a tomato leaf image to detect the disease.").launch()
app.py+12-2