debutts commited on
Commit
82d0d42
·
1 Parent(s): 9dbfead

model + examples + frontend

Browse files
Files changed (5) hide show
  1. app.py +17 -1
  2. bear-model.pkl +3 -0
  3. black.jpeg +0 -0
  4. grizzly.jpeg +0 -0
  5. teddy.jpeg +0 -0
app.py CHANGED
@@ -1,7 +1,23 @@
1
  import gradio as gr
 
 
 
2
 
3
  def greet(name):
4
  return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  iface.launch()
 
1
  import gradio as gr
2
+ from fastai.vision.all import *
3
+
4
+ from fastbook import *
5
 
6
  def greet(name):
7
  return "Hello " + name + "!!"
8
 
9
+ learn = load_learner('bear-model.pkl')
10
+
11
+ categories = ('Grizzly', 'Black', 'Teddy')
12
+
13
+ def classify_image(img):
14
+ pred,idx,probs = learn.predict(img)
15
+ return dict(zip(categories, map(float,probs)))
16
+
17
+ image = gr.inputs.Image(shape=(224,224))
18
+ label = gr.outputs.Label()
19
+
20
+ examples = ['black.jpeg', 'grizzly.jpeg', 'teddy.jpeg']
21
+
22
+ iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
23
  iface.launch()
bear-model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2d767a1631d89d075cf4db7c6cab59195d457c10d9e9cb8977ad4ce85a5d827a
3
+ size 46970767
black.jpeg ADDED
grizzly.jpeg ADDED
teddy.jpeg ADDED