Edward commited on
Commit
09a899f
·
1 Parent(s): 41bc980

add gradio

Browse files
Files changed (4) hide show
  1. app.py +18 -0
  2. box.jpg +0 -0
  3. kinderegg.jpg +0 -0
  4. trashrecycle_model.pt +3 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastcore.all import *
2
+ from fastai.vision.all import *
3
+ import gradio as gr
4
+
5
+ learn = load_learner('trashrecycle_model.pt')
6
+
7
+ categories = ("cardboard", "glass", "metal", "paper", "plastic", "non-recyclable")
8
+
9
+ def classify_img(img):
10
+ pred, idx, probs = learn.predict(img)
11
+ return dict(zip(categories, map(float, probs)))
12
+
13
+ image = gr.inputs.Image(shape=[225,225])
14
+ label = gr.outputs.Label()
15
+ examples = ["kinderegg.jpg", "box.jpg"]
16
+
17
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
18
+ intf.launch(inline=false)
box.jpg ADDED
kinderegg.jpg ADDED
trashrecycle_model.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:09d2262c2c6057207b27def1e4e3dfa62a8b45e1753c8df487ac8fc5ab82b6ea
3
+ size 47058581