Spaces:
Sleeping
Sleeping
vishalbakshi
commited on
Commit
·
f86b892
1
Parent(s):
0571bbe
initial commit with all files
Browse files- app.py +20 -0
- havanese.jpg +0 -0
- pets_model.pkl +3 -0
- requirements.txt +5 -0
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
__all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
|
2 |
+
|
3 |
+
from fastai.vision.all import *
|
4 |
+
import gradio as gr
|
5 |
+
import timm
|
6 |
+
|
7 |
+
learn = load_learner('pets_model.pkl')
|
8 |
+
|
9 |
+
categories = learn.dls.vocab
|
10 |
+
|
11 |
+
def classify_image(img):
|
12 |
+
pred,idx,probs = learn.predict(img)
|
13 |
+
return dict(zip(categories, map(float,probs)))
|
14 |
+
|
15 |
+
image = gr.inputs.Image(shape=(192, 192))
|
16 |
+
label = gr.outputs.Label()
|
17 |
+
examples = ['havanese.jpg']
|
18 |
+
|
19 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
20 |
+
intf.launch()
|
havanese.jpg
ADDED
pets_model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:572bc9988da035ea3da95ae4420cf6ef7d2cc8799eaca9953a44a0a5f7dd92ae
|
3 |
+
size 114806350
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
fastai==2.7.12
|
2 |
+
gradio==3.34.0
|
3 |
+
timm==0.9.2
|
4 |
+
torch==2.0.1
|
5 |
+
torchvision==0.15.2
|