Spaces:
Sleeping
Sleeping
socd06
commited on
Commit
·
38ac929
1
Parent(s):
8c32066
add examples, call gradio.components in interface
Browse files
app.py
CHANGED
@@ -2,8 +2,7 @@ import os
|
|
2 |
from huggingface_hub import from_pretrained_fastai
|
3 |
from fastai.vision.all import *
|
4 |
import gradio as gr
|
5 |
-
|
6 |
-
from gradio import Label
|
7 |
|
8 |
import pathlib
|
9 |
plt = platform.system()
|
@@ -11,7 +10,7 @@ if plt == 'Linux':
|
|
11 |
pathlib.WindowsPath = pathlib.PosixPath
|
12 |
|
13 |
learner = load_learner('model.pkl')
|
14 |
-
labels = learner.dls.vocab
|
15 |
|
16 |
|
17 |
def predict_fn(img):
|
@@ -20,6 +19,7 @@ def predict_fn(img):
|
|
20 |
|
21 |
|
22 |
gr.Interface(predict_fn,
|
23 |
-
Image(
|
24 |
-
outputs=Label(num_top_classes=
|
|
|
25 |
).launch()
|
|
|
2 |
from huggingface_hub import from_pretrained_fastai
|
3 |
from fastai.vision.all import *
|
4 |
import gradio as gr
|
5 |
+
|
|
|
6 |
|
7 |
import pathlib
|
8 |
plt = platform.system()
|
|
|
10 |
pathlib.WindowsPath = pathlib.PosixPath
|
11 |
|
12 |
learner = load_learner('model.pkl')
|
13 |
+
labels = tuple(learner.dls.vocab)
|
14 |
|
15 |
|
16 |
def predict_fn(img):
|
|
|
19 |
|
20 |
|
21 |
gr.Interface(predict_fn,
|
22 |
+
inputs=gr.components.Image(),
|
23 |
+
outputs=gr.components.Label(num_top_classes=8),
|
24 |
+
examples=['t.jpg', 'tbad.jpg', 'e.jpg', 'ebad.jpg'],
|
25 |
).launch()
|
e.jpg
ADDED
![]() |
ebad.jpg
ADDED
![]() |
t.jpg
ADDED
![]() |
tbad.jpg
ADDED
![]() |