Spaces:
Sleeping
Sleeping
Commit ·
40f485a
1
Parent(s): 70d0cfa
enable api
Browse files1 unmodified line234567891011121314151617182 unmodified lines21222324251 unmodified linefrom transformers import pipelinefrom PIL import Image# Load your modelmodel = pipeline("image-classification", model="wellCh4n/tomato-leaf-disease-classification-vit")# Define the prediction functiondef classify(image):if not isinstance(image, Image.Image):image = Image.fromarray(image)result = model(image)return result[0]['label'] # You can also return full result if you want scores# Define the interfaceapp = gr.Interface(fn=classify,inputs=gr.Image(type="pil"),2 unmodified linesdescription="Upload a tomato leaf image to detect the disease.")# 🚀 Enable both UI and APIapp.launch(show_api=True)1 unmodified line234567891011121314152 unmodified lines18192021221 unmodified linefrom transformers import pipelinefrom PIL import Imagemodel = pipeline("image-classification", model="wellCh4n/tomato-leaf-disease-classification-vit")def classify(image):if not isinstance(image, Image.Image):image = Image.fromarray(image)result = model(image)return result[0]['label']app = gr.Interface(fn=classify,inputs=gr.Image(type="pil"),2 unmodified linesdescription="Upload a tomato leaf image to detect the disease.")# 🚀 This is importantapp.launch(show_api=True)
app.py+2-5