Kornel Szabo commited on
Commit
5dd3b71
·
1 Parent(s): fe31411

Second commit

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -1,22 +1,22 @@
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: 02_spider_deploy.ipynb.
2
 
3
  # %% auto 0
4
- __all__ = ['learn', 'path', 'categories', 'image', 'output', 'examples', 'intf', 'second', 'classify_image']
5
 
6
- # %% 02_spider_deploy.ipynb 0
7
- from fastbook import *
 
 
8
 
9
  # %% 02_spider_deploy.ipynb 2
10
- import gradio as gr
 
11
 
12
  # %% 02_spider_deploy.ipynb 3
13
- learn = load_learner("spider.pkl")
14
-
15
- # %% 02_spider_deploy.ipynb 4
16
  path = Path("data/spiders")
17
  categories = learn.dls.vocab
18
 
19
- # %% 02_spider_deploy.ipynb 5
20
  def second(x):
21
  a, b = x
22
  return b
@@ -30,7 +30,7 @@ def classify_image(img):
30
  results = sorted(results, key=second, reverse=True)
31
  return dict(results[:10])
32
 
33
- # %% 02_spider_deploy.ipynb 7
34
  image = gr.inputs.Image()
35
  output = gr.outputs.Label()
36
  examples = ["data/spider1.jpg", "data/spider2.jpg"]
 
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: 02_spider_deploy.ipynb.
2
 
3
  # %% auto 0
4
+ __all__ = ['repo_id', 'learn', 'path', 'categories', 'image', 'output', 'examples', 'intf', 'second', 'classify_image']
5
 
6
+ # %% 02_spider_deploy.ipynb 1
7
+ from fastai.vision.all import *
8
+ from huggingface_hub import from_pretrained_fastai
9
+ import gradio as gr
10
 
11
  # %% 02_spider_deploy.ipynb 2
12
+ repo_id = "xt0r3/spider-classifier"
13
+ learn = from_pretrained_fastai(repo_id)
14
 
15
  # %% 02_spider_deploy.ipynb 3
 
 
 
16
  path = Path("data/spiders")
17
  categories = learn.dls.vocab
18
 
19
+ # %% 02_spider_deploy.ipynb 4
20
  def second(x):
21
  a, b = x
22
  return b
 
30
  results = sorted(results, key=second, reverse=True)
31
  return dict(results[:10])
32
 
33
+ # %% 02_spider_deploy.ipynb 6
34
  image = gr.inputs.Image()
35
  output = gr.outputs.Label()
36
  examples = ["data/spider1.jpg", "data/spider2.jpg"]