nirlevy98 commited on
Commit
842d4d7
1 Parent(s): 2aed509
Files changed (4) hide show
  1. app.py +6 -8
  2. model.pkl +2 -2
  3. polar.jpg +0 -0
  4. teddy.webp +0 -0
app.py CHANGED
@@ -1,22 +1,20 @@
1
  from fastai.vision.all import *
2
  import gradio as gr
3
 
4
- def is_teddy(x): return x[0].isupper()
5
-
6
  # Cell
7
- learn = load_learner('model.pk1')
8
 
9
  # Cell
10
- categories = ('Teddy', 'Grizzly')
11
 
12
  def classify_image(img):
13
- pred,idx,probs = learn. predict(img)
14
  return dict(zip(categories, map(float, probs) ))
15
 
16
  # Cell
17
- image = gr.inputs. Image(shape=(192, 192))
18
- label = gr. outputs.Label()
19
- examples = ['teddy.webp', 'grizzly.jpg', 'black.webp']
20
 
21
  intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
22
  intf.launch(inline=False)
 
1
  from fastai.vision.all import *
2
  import gradio as gr
3
 
 
 
4
  # Cell
5
+ learn = load_learner('model.pkl')
6
 
7
  # Cell
8
+ categories = learn.dls.vocab
9
 
10
  def classify_image(img):
11
+ pred,idx,probs = learn.predict(img)
12
  return dict(zip(categories, map(float, probs) ))
13
 
14
  # Cell
15
+ image = gr.components.Image()
16
+ label = gr.components.Label()
17
+ examples = ['teddy.webp', 'grizzly.jpg', 'black.webp', 'polar.jpg']
18
 
19
  intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
20
  intf.launch(inline=False)
model.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e09a5c266b5956bdb8a8fb2b4c1e23c8295b77d664c822ff2d321875670ff9ca
3
- size 46969150
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e14c5d86dd7855ee29ea8706c75b6043e6bd500dae4b653660255871cdf413a7
3
+ size 46968077
polar.jpg ADDED
teddy.webp CHANGED