ntrinh commited on
Commit
708b6ca
·
1 Parent(s): 4779d88

let's deploy to hugging space

Browse files
Files changed (4) hide show
  1. app.py +35 -0
  2. pets_classifier_model.pkl +3 -0
  3. requirements.txt +5 -0
  4. samoyed.jpg +0 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: app1.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'description', 'intf', 'classify_image']
5
+
6
+ # %% app1.ipynb 2
7
+ from fastai.vision.all import *
8
+ import gradio as gr
9
+ import timm
10
+
11
+ # %% app1.ipynb 3
12
+ learn = load_learner('pets_classifier_model.pkl')
13
+
14
+ # %% app1.ipynb 5
15
+ categories = learn.dls.vocab
16
+
17
+ def classify_image(img):
18
+ pred,idx,probs = learn.predict(img)
19
+ return dict(zip(categories,map(float,probs)))
20
+
21
+ # %% app1.ipynb 6
22
+ image = gr.inputs.Image(shape=(192,192))
23
+ label = gr.outputs.Label()
24
+ examples = ['samoyed.jpg']
25
+ description="A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Deep Learning app using HuggingFace Spaces and Gradio"
26
+
27
+ # %% app1.ipynb 7
28
+ intf = gr.Interface(fn=classify_image,
29
+ inputs=image,
30
+ outputs=label,
31
+ title="Pets classifier",
32
+ description=description,
33
+ interpretation='default',
34
+ examples=examples, enable_queue=True)
35
+ intf.launch(inline=False)
pets_classifier_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7afbd6422233f7f01b0a5fcd3558c9e20179cf19d37d5fa4e02a76577f4c6fac
3
+ size 114808625
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ fastai
2
+ gradio
3
+ timm
4
+ torch
5
+ torchvision
samoyed.jpg ADDED