Spaces:
Sleeping
Sleeping
Commit
·
908e19f
1
Parent(s):
40f485a
Fix: disable SSR to enable API
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import gradio as gr
|
|
| 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):
|
|
@@ -10,6 +11,7 @@ def classify(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,5 +20,5 @@ app = gr.Interface(
|
|
| 18 |
description="Upload a tomato leaf image to detect the disease."
|
| 19 |
)
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
app.launch(show_api=True)
|
|
|
|
| 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 |
def classify(image):
|
|
|
|
| 11 |
result = model(image)
|
| 12 |
return result[0]['label']
|
| 13 |
|
| 14 |
+
# Define the interface
|
| 15 |
app = gr.Interface(
|
| 16 |
fn=classify,
|
| 17 |
inputs=gr.Image(type="pil"),
|
|
|
|
| 20 |
description="Upload a tomato leaf image to detect the disease."
|
| 21 |
)
|
| 22 |
|
| 23 |
+
# ✅ Disable SSR to enable API correctly
|
| 24 |
+
app.launch(show_api=True, ssr=False)
|