Spaces:
Sleeping
Sleeping
Commit
·
40f485a
1
Parent(s):
70d0cfa
enable api
Browse files
app.py
CHANGED
|
@@ -2,17 +2,14 @@ import gradio as gr
|
|
| 2 |
from transformers import pipeline
|
| 3 |
from PIL import Image
|
| 4 |
|
| 5 |
-
# Load your model
|
| 6 |
model = pipeline("image-classification", model="wellCh4n/tomato-leaf-disease-classification-vit")
|
| 7 |
|
| 8 |
-
# Define the prediction function
|
| 9 |
def classify(image):
|
| 10 |
if not isinstance(image, Image.Image):
|
| 11 |
image = Image.fromarray(image)
|
| 12 |
result = model(image)
|
| 13 |
-
return result[0]['label']
|
| 14 |
|
| 15 |
-
# Define the interface
|
| 16 |
app = gr.Interface(
|
| 17 |
fn=classify,
|
| 18 |
inputs=gr.Image(type="pil"),
|
|
@@ -21,5 +18,5 @@ app = gr.Interface(
|
|
| 21 |
description="Upload a tomato leaf image to detect the disease."
|
| 22 |
)
|
| 23 |
|
| 24 |
-
# 🚀
|
| 25 |
app.launch(show_api=True)
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
from PIL import Image
|
| 4 |
|
|
|
|
| 5 |
model = pipeline("image-classification", model="wellCh4n/tomato-leaf-disease-classification-vit")
|
| 6 |
|
|
|
|
| 7 |
def classify(image):
|
| 8 |
if not isinstance(image, Image.Image):
|
| 9 |
image = Image.fromarray(image)
|
| 10 |
result = model(image)
|
| 11 |
+
return result[0]['label']
|
| 12 |
|
|
|
|
| 13 |
app = gr.Interface(
|
| 14 |
fn=classify,
|
| 15 |
inputs=gr.Image(type="pil"),
|
|
|
|
| 18 |
description="Upload a tomato leaf image to detect the disease."
|
| 19 |
)
|
| 20 |
|
| 21 |
+
# 🚀 This is important
|
| 22 |
app.launch(show_api=True)
|