SantiagoRO commited on
Commit
2811d6e
1 Parent(s): 0973e4c
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -1,28 +1,25 @@
1
-
2
- __all__ = ['is_cat','learn','classify_image','categories','image','label','examples','intf']
3
 
4
  # Cell
5
  from fastai.vision.all import *
6
  import gradio as gr
7
-
8
-
9
- def is_cat(x): return x[0].isupper()
10
 
11
  # Cell
12
  learn = load_learner('model.pkl')
13
 
14
-
15
  # Cell
16
- categories = ('Dog', 'Cat')
17
 
18
  def classify_image(img):
19
- pred, idx, probs = learn.predict(img)
20
- return dict(zip(categories, map(float, probs)))
21
 
22
  # Cell
23
  image = gr.inputs.Image(shape=(192, 192))
24
  label = gr.outputs.Label()
25
- examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
26
 
 
27
  intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
28
- intf.launch(inline=False)
 
1
+ __all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
 
2
 
3
  # Cell
4
  from fastai.vision.all import *
5
  import gradio as gr
6
+ import timm
 
 
7
 
8
  # Cell
9
  learn = load_learner('model.pkl')
10
 
 
11
  # Cell
12
+ categories = learn.dls.vocab
13
 
14
  def classify_image(img):
15
+ pred,idx,probs = learn.predict(img)
16
+ return dict(zip(categories, map(float,probs)))
17
 
18
  # Cell
19
  image = gr.inputs.Image(shape=(192, 192))
20
  label = gr.outputs.Label()
21
+ examples = ['dog.jpg','cat.jpg']
22
 
23
+ # Cell
24
  intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
25
+ intf.launch()