vietngth commited on
Commit
23baf3a
Β·
1 Parent(s): 4305c31

Add application

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['loaded_learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image']
5
+
6
+ # %% app.ipynb 3
7
+ loaded_learn = load_learner('model.pkl')
8
+ categories = ("Dog", "Cat")
9
+ def classify_image(img):
10
+ pred, idx, probs = loaded_learn.predict(img)
11
+ return dict(zip(categories, map(float, probs)))
12
+ image = gr.inputs.Image(shape=(192, 192))
13
+ label = gr.outputs.Label()
14
+ examples = ["doggo.jpg", "catto.jpg", "test.jpg"]
15
+
16
+ intf = gr.Interface(
17
+ fn=classify_image,
18
+ inputs=image,
19
+ outputs=label,
20
+ examples=examples
21
+ )
22
+ intf.launch(inline=False, share=True)