8uydz
commited on
Commit
·
99276f9
1
Parent(s):
a27c221
pet classify app
Browse files
app.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:02eb3a56c6194f7249d17c6ce92fc59c068a0c35e0fc3d552402eae8c7a0f346
|
3 |
+
size 114778679
|
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
__all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
|
2 |
+
|
3 |
+
# Cell
|
4 |
+
from fastai.vision.all import *
|
5 |
+
import gradio as gr
|
6 |
+
import timm
|
7 |
+
|
8 |
+
# Cell
|
9 |
+
learn = load_learner('model.pkl')
|
10 |
+
|
11 |
+
# Cell
|
12 |
+
categories = learn.dls.vocab
|
13 |
+
|
14 |
+
def classify_image(img):
|
15 |
+
pred,idx,probs = learn.predict(img)
|
16 |
+
return dict(zip(categories, map(float,probs)))
|
17 |
+
|
18 |
+
# Cell
|
19 |
+
image = gr.inputs.Image(shape=(192, 192))
|
20 |
+
label = gr.outputs.Label()
|
21 |
+
examples = ['basset.jpg']
|
22 |
+
|
23 |
+
# Cell
|
24 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
25 |
+
intf.launch()
|