Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,36 @@
|
|
1 |
import gradio as gr
|
2 |
from fastai.vision.all import *
|
3 |
import skimage
|
|
|
4 |
|
5 |
learn = load_learner('learner.pkl')
|
6 |
-
|
7 |
labels = learn.dls.vocab
|
|
|
8 |
def predict(img):
|
9 |
img = PILImage.create(img)
|
10 |
pred,pred_idx,probs = learn.predict(img)
|
11 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
12 |
|
13 |
-
import os
|
14 |
for root, dirs, files in os.walk(r'sample_images/'):
|
15 |
for filename in files:
|
16 |
print(filename)
|
17 |
|
18 |
title = "Paddy Disease Classifier with EdgeNeXt"
|
19 |
-
description = "
|
20 |
interpretation='default'
|
21 |
examples = ["sample_images/"+file for file in files]
|
22 |
article="<p style='text-align: center'><a href='https://dicksonneoh.com/portfolio/pytorch_at_the_edge_timm_torchscript_flutter/' target='_blank'>Blog post</a></p>"
|
23 |
enable_queue=True
|
24 |
|
25 |
-
gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from fastai.vision.all import *
|
3 |
import skimage
|
4 |
+
import os
|
5 |
|
6 |
learn = load_learner('learner.pkl')
|
|
|
7 |
labels = learn.dls.vocab
|
8 |
+
|
9 |
def predict(img):
|
10 |
img = PILImage.create(img)
|
11 |
pred,pred_idx,probs = learn.predict(img)
|
12 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
13 |
|
|
|
14 |
for root, dirs, files in os.walk(r'sample_images/'):
|
15 |
for filename in files:
|
16 |
print(filename)
|
17 |
|
18 |
title = "Paddy Disease Classifier with EdgeNeXt"
|
19 |
+
description = "9 Diseases + 1 Normal class."
|
20 |
interpretation='default'
|
21 |
examples = ["sample_images/"+file for file in files]
|
22 |
article="<p style='text-align: center'><a href='https://dicksonneoh.com/portfolio/pytorch_at_the_edge_timm_torchscript_flutter/' target='_blank'>Blog post</a></p>"
|
23 |
enable_queue=True
|
24 |
|
25 |
+
gr.Interface(
|
26 |
+
fn=predict,
|
27 |
+
inputs=gr.inputs.Image(shape=(224, 224)),
|
28 |
+
outputs=gr.outputs.Label(num_top_classes=3),
|
29 |
+
title=title,
|
30 |
+
description=description,
|
31 |
+
article=article,
|
32 |
+
examples=examples,
|
33 |
+
interpretation=interpretation,
|
34 |
+
enable_queue=enable_queue,
|
35 |
+
theme="grass",
|
36 |
+
).launch()
|