Joao Henrique
commited on
Commit
·
caf89b7
1
Parent(s):
a4e10ba
app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
|
4 |
+
learn = load_learner('model.pkl')
|
5 |
+
|
6 |
+
labels = learn.dls.vocab
|
7 |
+
examples = ['tlou.png', 'tw.png', 'ds.png', 'dmc.png', 'mgs.jpg', 'rdr.png']
|
8 |
+
|
9 |
+
|
10 |
+
def predict(img):
|
11 |
+
img = PILImage.create(img)
|
12 |
+
pred, pred_idx, probs = learn.predict(img)
|
13 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
14 |
+
|
15 |
+
|
16 |
+
gr.Interface(fn=predict,
|
17 |
+
inputs=gr.components.Image(shape=(512, 512)),
|
18 |
+
outputs=gr.components.Label(num_top_classes=6),
|
19 |
+
examples=examples
|
20 |
+
).launch(share=False)
|
21 |
+
|