iamalos commited on
Commit
b3ed5ec
1 Parent(s): 3f40fbf

fix app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -1,15 +1,16 @@
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
2
 
3
  # %% auto 0
4
- __all__ = ['labels', 'title', 'description', 'article', 'image', 'label', 'examples', 'interpretation', 'enable_queue', 'intf',
5
- 'classify_image']
6
 
7
  # %% app.ipynb 1
8
  from fastai.vision.all import *
9
  import scipy
10
  import gradio as gr
11
 
12
- # %% app.ipynb 3
 
13
  labels = learner.dls.vocab
14
 
15
  def classify_image(img):
@@ -20,7 +21,7 @@ def classify_image(img):
20
  pred, pred_idx, probs = learner.predict(img)
21
  return dict(zip(labels, map(float, probs)))
22
 
23
- # %% app.ipynb 4
24
  title = "Cat & Dog Breed Classifier"
25
  description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
26
  article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
@@ -40,4 +41,3 @@ intf = gr.Interface(classify_image,
40
  interpretation=interpretation)
41
 
42
  intf.launch(enable_queue=enable_queue)
43
-
 
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
2
 
3
  # %% auto 0
4
+ __all__ = ['learner', 'labels', 'title', 'description', 'article', 'image', 'label', 'examples', 'interpretation', 'enable_queue',
5
+ 'intf', 'classify_image']
6
 
7
  # %% app.ipynb 1
8
  from fastai.vision.all import *
9
  import scipy
10
  import gradio as gr
11
 
12
+ # %% app.ipynb 2
13
+ learner = load_learner('pet_learner.pkl')
14
  labels = learner.dls.vocab
15
 
16
  def classify_image(img):
 
21
  pred, pred_idx, probs = learner.predict(img)
22
  return dict(zip(labels, map(float, probs)))
23
 
24
+ # %% app.ipynb 3
25
  title = "Cat & Dog Breed Classifier"
26
  description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
27
  article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
 
41
  interpretation=interpretation)
42
 
43
  intf.launch(enable_queue=enable_queue)