ludjan commited on
Commit
2389515
1 Parent(s): c8196ab
Files changed (2) hide show
  1. app.py +18 -5
  2. model.pkl +0 -3
app.py CHANGED
@@ -1,10 +1,23 @@
 
 
 
1
  import gradio as gr
 
 
 
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
5
 
6
- cycles = ['unicycle.jpeg', 'bicycle.jpeg', 'tricycle.png']
 
7
 
8
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
9
- iface.launch()
10
 
 
 
 
1
+ __all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
2
+
3
+ from fastai.vision.all import *
4
  import gradio as gr
5
+ import timm
6
+
7
+ # Upload your model
8
+ learn = load_learner('model (1).pkl')
9
+
10
+ categories = learn.dls.vocab
11
 
12
+ def classify_image(img):
13
+ pred,idx,probs = learn.predict(img)
14
+ return dict(zip(categories, map(float,probs)))
15
 
16
+ image = gr.Image()
17
+ label = gr.Label()
18
 
19
+ # Upload your own images and link them
20
+ examples = ['unicycle.jpeg', 'bicycle.jpeg', 'tricycle.png']
21
 
22
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
23
+ intf.launch()
model.pkl DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:289406d996c0060f0cc8ef26c42971bdb27cfa389938f0f928045e734b079ae0
3
- size 47061355