Shuo Wang
commited on
Commit
•
1b29a2b
1
Parent(s):
8649f21
let's deploy
Browse files- app.py +22 -0
- export.pkl +3 -0
- grizzly.jpg +0 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
learn = load_learner('export.pkl')
|
5 |
+
labels = learn.dls.vocab
|
6 |
+
def predict(img):
|
7 |
+
img = PILImage.create(img)
|
8 |
+
pred,pred_idx,probs = learn.predict(img)
|
9 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
10 |
+
|
11 |
+
title = "Bear Classifier"
|
12 |
+
description = "A bear classifier trained on downloaded images of bear dataset with fastai."
|
13 |
+
article="<p style='text-align: center'><a href='https://shuowangphd.github.io' target='_blank'>Back to my personal webpage.</a></p>"
|
14 |
+
exa = ['grizzly.jpg']
|
15 |
+
interpretation='default'
|
16 |
+
enable_queue=True
|
17 |
+
|
18 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)),
|
19 |
+
outputs=gr.outputs.Label(num_top_classes=3),
|
20 |
+
title=title,
|
21 |
+
description=description,article=article,examples=exa,
|
22 |
+
interpretation=interpretation,enable_queue=enable_queue).launch()
|
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:835dab7fffe8aec0848119fc870b005911fdaddff8944bb90e16dd169a15515e
|
3 |
+
size 46965909
|
grizzly.jpg
ADDED
![]() |
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|