danielp1402 commited on
Commit
18040a3
1 Parent(s): bfea15f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -8
app.py CHANGED
@@ -1,13 +1,25 @@
 
 
 
 
 
1
  import gradio as gr
 
 
 
 
 
 
2
 
3
- def greet(name, intensity):
4
- return "Hello " * intensity + name + "!"
 
5
 
6
- demo = gr.Interface(
7
- fn=greet,
8
- inputs=["text", "slider"],
9
- outputs=["text"],
10
- )
11
 
12
- demo.launch()
 
13
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: . (unless otherwise specified).
2
+
3
+ __all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
4
+
5
+ from fastai.vision.all import *
6
  import gradio as gr
7
+ import timm
8
+
9
+ # Upload your model
10
+ learn = load_learner('model.pkl')
11
+
12
+ categories = learn.dls.vocab
13
 
14
+ def classify_image(img):
15
+ pred,idx,probs = learn.predict(img)
16
+ return dict(zip(categories, map(float,probs)))
17
 
18
+ image = gr.Image()
19
+ label = gr.Label()
 
 
 
20
 
21
+ # Upload your own images and link them
22
+ examples = ['basset.jpg']
23
 
24
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
25
+ intf.launch()