GKarol commited on
Commit
fc1618a
1 Parent(s): cd8c666

Upload images and model files

Browse files
Files changed (5) hide show
  1. app.py +54 -0
  2. bear-classifier.pkl +3 -0
  3. black.jpeg +0 -0
  4. grizzly.jpeg +0 -0
  5. teddy.jpeg +0 -0
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: gradio-bear-classifier.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['label_function', 'learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image']
5
+
6
+ # %% gradio-bear-classifier.ipynb 4
7
+ from fastai.vision.all import *
8
+ import gradio as gr
9
+
10
+ # %% gradio-bear-classifier.ipynb 5
11
+ label_function = parent_label
12
+
13
+ # %% gradio-bear-classifier.ipynb 7
14
+ learn = load_learner('export.pkl')
15
+
16
+ # %% gradio-bear-classifier.ipynb 9
17
+ categories = ("grizzly", "black", "teddy")
18
+
19
+ def classify_image(img):
20
+ pred,idx,probs = learn.predict(img)
21
+ return dict(zip(categories, map(float,probs)))
22
+
23
+ # %% gradio-bear-classifier.ipynb 11
24
+ image = gr.inputs.Image(shape=(192, 192))
25
+ label = gr.outputs.Label()
26
+ examples = ['grizzly.jpeg', 'black.jpeg', 'teddy.jpeg']
27
+
28
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
29
+ intf.launch(inline=False)
30
+
31
+ # %% gradio-bear-classifier.ipynb 23
32
+ from fastai.vision.all import *
33
+ import gradio as gr
34
+
35
+ # %% gradio-bear-classifier.ipynb 24
36
+ label_function = parent_label
37
+
38
+ # %% gradio-bear-classifier.ipynb 26
39
+ learn = load_learner('bear-classifier.pkl')
40
+
41
+ # %% gradio-bear-classifier.ipynb 28
42
+ categories = ("black", "grizzly", "teddy")
43
+
44
+ def classify_image(img):
45
+ pred,idx,probs = learn.predict(img)
46
+ return dict(zip(categories, map(float,probs)))
47
+
48
+ # %% gradio-bear-classifier.ipynb 30
49
+ image = gr.inputs.Image(shape=(192, 192))
50
+ label = gr.outputs.Label()
51
+ examples = ['grizzly.jpeg', 'black.jpeg', 'teddy.jpeg']
52
+
53
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
54
+ intf.launch(inline=False)
bear-classifier.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4918fa6ff86ceb36006b3ea34e51dfbbd54735c4864738ced31cba1b36af5163
3
+ size 46973263
black.jpeg ADDED
grizzly.jpeg ADDED
teddy.jpeg ADDED