李根赢 commited on
Commit
0519ac9
1 Parent(s): 13b99bb
Files changed (1) hide show
  1. app.py +1 -19
app.py CHANGED
@@ -1,13 +1,12 @@
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb.
2
 
3
  # %% auto 0
4
- __all__ = ['learn_inf', 'lbl_pred', 'image', 'label', 'examples', 'intf', 'btn_upload', 'classify_image', 'on_click_classify']
5
 
6
  # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 25
7
  from fastai.vision.all import *
8
  import gradio as gr
9
 
10
-
11
  # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 27
12
  learn_inf = load_learner('bears/export.pkl')
13
 
@@ -25,20 +24,3 @@ label = gr.Label()
25
  examples = ['images/black.jpg', 'images/grizzly.jpg', 'images/teddy.jpg']
26
  intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
27
  intf.launch(inline=False, debug=True)
28
-
29
- # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 35
30
- def on_click_classify(change):
31
- img = PILImage.create(btn_upload.data[-1])
32
- out_pl.clear_output()
33
- with out_pl: display(img.to_thumb(128,128))
34
- pred,pred_idx,probs = learn_inf.predict(img)
35
- lbl_pred.value = f'Prediction: {pred}; Probability: {probs[pred_idx]:.04f}'
36
-
37
- btn_run.on_click(on_click_classify)
38
-
39
- # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 36
40
- btn_upload = widgets.FileUpload()
41
-
42
- # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 37
43
- VBox([widgets.Label('Select your bear!'),
44
- btn_upload, btn_run, out_pl, lbl_pred])
 
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb.
2
 
3
  # %% auto 0
4
+ __all__ = ['learn_inf', 'lbl_pred', 'image', 'label', 'examples', 'intf', 'classify_image']
5
 
6
  # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 25
7
  from fastai.vision.all import *
8
  import gradio as gr
9
 
 
10
  # %% gdrive/MyDrive/Colab Notebooks/Untitled8.ipynb 27
11
  learn_inf = load_learner('bears/export.pkl')
12
 
 
24
  examples = ['images/black.jpg', 'images/grizzly.jpg', 'images/teddy.jpg']
25
  intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
26
  intf.launch(inline=False, debug=True)