sbansal28 commited on
Commit
9d28afc
·
verified ·
1 Parent(s): cdc947d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
2
+
3
+ from fastai.vision.all import *
4
+ import gradio as gr
5
+
6
+ learn = load_learner('/kaggle/input/beach-pkl-test/export.pkl')
7
+
8
+ categories = ('Barnacles', 'Flowers', 'Grass', 'Kelp', 'Mussels', 'Primrose', 'Sage_Bush', 'SeaGull', 'Seashells')
9
+ def classify_image(img):
10
+ pred, idx, probs = learn.predict(img)
11
+ return dict(zip(categories, map(float, probs)))
12
+
13
+ image=gr.Image(height = 192, width = 192)
14
+ label = gr.Label()
15
+ examples = ['105a9dad-f329-4cfc-b3e3-52ef9334111f.jpg','095f0070-b680-4dbb-aca9-8451129a41bc.jpg', '0ecf9374-9120-4e75-9fc1-6633e61f6115.jpg', '22332b64-118f-48f5-b92b-e2f997d1a8cc.jpg', '270ab7a9-1c17-49b1-b1fe-9827b59aca9c.jpg', '061b7222-e979-4fcf-8454-78b6c879f5f0.jpg', '141747ba-db2a-4d67-af59-dccfa844ba51.jpg', '0cf94408-5399-4754-aba5-5f8bafbd71fd.jpg', '06dc143b-21b9-4dc0-979c-7b6801252cc7.jpg' ]
16
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
17
+ intf.launch(inline=False)