Jerwin Pouwelse commited on
Commit
362c1c0
1 Parent(s): ef211ca
Files changed (5) hide show
  1. app.py +32 -0
  2. black.jpg +0 -0
  3. dog.jpg +0 -0
  4. grizzly.jpg +0 -0
  5. teddy.jpg +0 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learner', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image']
5
+
6
+ # %% ../app.ipynb 2
7
+ from fastai.vision.all import *
8
+ import gradio as gr
9
+
10
+ # def is_cat(x):
11
+ # x[0].is_upper()
12
+
13
+ # %% ../app.ipynb 5
14
+ learner = load_learner("export2.pkl")
15
+
16
+ # %% ../app.ipynb 7
17
+ categories = ("black", "grizzly", "teddy")
18
+
19
+ def classify_image(im):
20
+ pred, idx, probs = learner.predict(im)
21
+ return dict(zip(categories, map(float, probs)))
22
+
23
+
24
+ # %% ../app.ipynb 11
25
+ image = gr.inputs.Image(shape=(192, 192))
26
+ label = gr.outputs.Label()
27
+ examples = ["teddy.jpg", "grizzly.jpg", "black.jpg"]
28
+
29
+ #intf = gr.Interface(fn=classify_image, inputs="image", outputs="label", examples=examples)
30
+ #intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
31
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
32
+ intf.launch(inline=False)
black.jpg ADDED
dog.jpg ADDED
grizzly.jpg ADDED
teddy.jpg ADDED