Michela Ledwidge commited on
Commit
35f6f2d
·
1 Parent(s): aa501e9

cleaned up autogen code so also runs in notebook

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -1,28 +1,31 @@
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../02_production.ipynb.
2
 
3
  # %% auto 0
4
- __all__ = ['categories', 'learn', 'image', 'label', 'file_list', 'stem', 'examples', 'intf', 'classify_image']
5
 
6
- # %% ../02_production.ipynb 53
7
  from fastai.vision.all import *
8
  import gradio as gr
9
 
10
- # %% ../02_production.ipynb 55
11
  categories = ('black','grizzly','teddy')
12
 
13
- # %% ../02_production.ipynb 56
14
  def classify_image(img):
15
  pred,idx, probs = learn.predict(img)
16
  return dict(zip(categories, map(float,probs)))
17
 
18
- # %% ../02_production.ipynb 58
19
- learn = load_learner('model.pkl')
 
20
 
 
 
21
  image = gr.components.Image(width=224, height=224)
22
  label = gr.components.Label()
23
 
24
  file_list = ['grizzly.jpg', 'black.jpg', 'teddy.jpg']
25
- stem = 'examples/'
26
  examples = list(map(lambda x: stem + x, file_list))
27
 
28
  intf = gr.Interface(fn=classify_image, inputs=image, outputs=label,examples=examples)
 
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../02_production.ipynb.
2
 
3
  # %% auto 0
4
+ __all__ = ['categories', 'model', 'stem', 'learn', 'image', 'label', 'file_list', 'examples', 'intf', 'classify_image']
5
 
6
+ # %% ../02_production.ipynb 52
7
  from fastai.vision.all import *
8
  import gradio as gr
9
 
10
+ # %% ../02_production.ipynb 54
11
  categories = ('black','grizzly','teddy')
12
 
13
+ # %% ../02_production.ipynb 57
14
  def classify_image(img):
15
  pred,idx, probs = learn.predict(img)
16
  return dict(zip(categories, map(float,probs)))
17
 
18
+ # %% ../02_production.ipynb 59
19
+ model = 'model.pkl'
20
+ stem = 'examples/'
21
 
22
+ # %% ../02_production.ipynb 61
23
+ learn = load_learner(model)
24
  image = gr.components.Image(width=224, height=224)
25
  label = gr.components.Label()
26
 
27
  file_list = ['grizzly.jpg', 'black.jpg', 'teddy.jpg']
28
+
29
  examples = list(map(lambda x: stem + x, file_list))
30
 
31
  intf = gr.Interface(fn=classify_image, inputs=image, outputs=label,examples=examples)