jjglilleberg commited on
Commit
775f235
1 Parent(s): 3ad7096

add application files

Browse files
Files changed (5) hide show
  1. .DS_Store +0 -0
  2. app.py +30 -0
  3. coffee.jpg +0 -0
  4. export.pkl +3 -0
  5. tea.jpg +0 -0
.DS_Store ADDED
Binary file (6.15 kB). View file
 
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../../../../../Colab Notebooks/Ch2.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learn_inf', 'categories', 'examples', 'demo', 'classify_image']
5
+
6
+ # %% ../../../../../Colab Notebooks/Ch2.ipynb 26
7
+ from fastai.vision.all import *
8
+ import gradio as gr
9
+
10
+ # %% ../../../../../Colab Notebooks/Ch2.ipynb 27
11
+ learn_inf = load_learner('export.pkl')
12
+
13
+ # %% ../../../../../Colab Notebooks/Ch2.ipynb 30
14
+ categories = learn_inf.dls.vocab
15
+
16
+ # %% ../../../../../Colab Notebooks/Ch2.ipynb 31
17
+ def classify_image(img):
18
+ learn_inf.predict(img)
19
+ pred, idx, probs = learn_inf.predict(img)
20
+ print(pred, idx, probs)
21
+ return dict(zip(categories, map(float, probs)))
22
+
23
+ # %% ../../../../../Colab Notebooks/Ch2.ipynb 33
24
+ examples=['tea.jpg', 'coffee.jpg']
25
+ demo = gr.Interface(
26
+ fn=classify_image,
27
+ inputs=gr.Image(),
28
+ outputs=gr.Label(),
29
+ examples=examples)
30
+ demo.launch()
coffee.jpg ADDED
export.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:399c936b57b604b412f595d9e1257f1b1b2c8da8db9626f44d638b17c56565fc
3
+ size 46967678
tea.jpg ADDED