mgogov commited on
Commit
e2490f0
·
1 Parent(s): bc2a41f
Files changed (1) hide show
  1. app.py +26 -4
app.py CHANGED
@@ -1,7 +1,29 @@
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- def greet(name):
4
- return f"Sup, {name} 🤙?"
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learn', 'categories', 'image', 'label', 'intf', 'classify_image']
5
+
6
+ # %% ../app.ipynb 2
7
+ from fastai.vision.all import *
8
+ from PIL import Image
9
+ import matplotlib.pyplot as plt
10
  import gradio as gr
11
+ from nbdev.export import nb_export
12
+
13
+ # %% ../app.ipynb 5
14
+ learn = load_learner('models/02.pkl')
15
+
16
+ # %% ../app.ipynb 7
17
+ categories = ('tfs', 'xk', 'dbt', 'pbs', 'rwo', 'hth', 'itb')
18
+
19
+ def classify_image(img):
20
+ pred, idx, probs = learn.predict(img)
21
+
22
+ return dict(zip(sorted(categories), map(float, probs)))
23
 
24
+ # %% ../app.ipynb 9
25
+ image = gr.Image(height=192, width=192)
26
+ label = gr.Label()
27
 
28
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=example_image_paths)
29
+ intf.launch(inline=False)