dpv commited on
Commit
dd1a0e3
1 Parent(s): 672f11e

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import*
2
+ import gradio as gr
3
+ learn2 = load_learner('stage2.pkl')
4
+
5
+ categories2 = 'HDPE container', 'PET plastic bottle', 'aluminium can', 'cardboard', 'glass', 'paper2D', 'paper3D', 'steel and tin cans'
6
+
7
+
8
+ def classify_stage2(img):
9
+ pred, idx, probs = learn2.predict(img)
10
+ return dict(zip(categories2, map(float,probs)))
11
+
12
+ image2 = gr.inputs.Image(shape=(192,192))
13
+ label2 = gr.outputs.Label()
14
+ examples2 = ['stage2ex1_t.jpeg', 'stage2ex2_t.jpeg','stage2ex3_t.jpeg', 'stage2ex4_t.jpeg','stage2ex5_t.jpeg',
15
+ 'stage2ex6_tt.jpeg','stage2ex7_tt.jpeg','stage2ex8_t.jpeg']
16
+ intf2 = gr.Interface(fn=classify_stage2, inputs = image2, outputs = label2, examples = examples2)
17
+ intf2.launch(inline=False)