daspartho commited on
Commit
263d1ef
1 Parent(s): 9d41088

added model and interface

Browse files
Files changed (6) hide show
  1. app.py +13 -3
  2. cactus.jpg +0 -0
  3. dog.jpg +0 -0
  4. lego.jpg +0 -0
  5. model.pkl +3 -0
  6. plushie.jpg +0 -0
app.py CHANGED
@@ -1,7 +1,17 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
 
7
  iface.launch()
 
1
  import gradio as gr
2
+ from fastai.vision.all import *
3
 
4
+ learn_inf = load_learner('model.pkl')
5
+ categories = learn_inf.dls.vocab
6
 
7
+ def classify_image(img):
8
+ pred,pred_idx,probs = learn_inf.predict(img)
9
+ return dict(zip(categories, map(float, probs)))
10
+
11
+ iface = gr.Interface(
12
+ fn=classify_image,
13
+ inputs=gr.inputs.Image(shape=(224,224)),
14
+ outputs=gr.outputs.Label(),
15
+ examples=['lego.jpg', 'dog.jpg', 'cactus.jpg', 'plushie.jpg']
16
+ )
17
  iface.launch()
cactus.jpg ADDED
dog.jpg ADDED
lego.jpg ADDED
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a72e6aed40f299c03e785a1d114e84dde2511b1d8e81e415945dec9e482a793e
3
+ size 46963557
plushie.jpg ADDED