李根赢 commited on
Commit
bba1729
1 Parent(s): dc7601d
Files changed (2) hide show
  1. app.py +16 -7
  2. images/grizzly.jpg +0 -0
app.py CHANGED
@@ -1,20 +1,29 @@
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb.
2
 
3
  # %% auto 0
4
- __all__ = ['path', 'learn_inf', 'btn_upload', 'pred', 'pred_idx', 'probs']
5
 
6
- # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 24
7
  from fastai.vision.widgets import *
8
  from fastai.vision.all import *
9
  import gradio as gr
10
 
11
- # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 25
12
- # path = Path('bears')
13
- learn_inf = load_learner('export.pkl')
14
-
15
  # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 26
 
 
 
 
16
  btn_upload = widgets.FileUpload()
17
  btn_upload
18
 
 
 
 
 
 
 
19
  # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 30
20
- pred,pred_idx,probs = learn_inf.predict(img)
 
 
 
 
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb.
2
 
3
  # %% auto 0
4
+ __all__ = ['path', 'learn_inf', 'btn_upload', 'img', 'out_pl']
5
 
6
+ # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 25
7
  from fastai.vision.widgets import *
8
  from fastai.vision.all import *
9
  import gradio as gr
10
 
 
 
 
 
11
  # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 26
12
+ path = Path('bears')
13
+ learn_inf = load_learner(path/'export.pkl')
14
+
15
+ # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 27
16
  btn_upload = widgets.FileUpload()
17
  btn_upload
18
 
19
+ # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 28
20
+ btn_upload = SimpleNamespace(data = ['images/grizzly.jpg'])
21
+
22
+ # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 29
23
+ img = PILImage.create(btn_upload.data[-1])
24
+
25
  # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 30
26
+ out_pl = widgets.Output()
27
+ out_pl.clear_output()
28
+ with out_pl: display(img.to_thumb(128,128))
29
+ out_pl
images/grizzly.jpg ADDED