Alexit0 commited on
Commit
402a830
·
verified ·
1 Parent(s): 5f7608c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -3
app.py CHANGED
@@ -1,7 +1,27 @@
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
 
5
+ learn = load_learner('model.pkl')
6
+ labels = learn.dls.vocab
7
+
8
+
9
+ def predict(img):
10
+ img = PILImage.create(img)
11
+ pred, pred_idx, probs = learn.predict(img)
12
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
+
14
+
15
+ title = "Simpsons classifier"
16
+ description = "Quick Fastai classifier for simpsons."
17
+ examples = ['bart.png', 'homer.png']
18
+
19
+ gr.Interface(
20
+ fn=predict,
21
+ inputs=gr.Image(),
22
+ outputs=gr.Label(num_top_classes=2),
23
+ title=title,
24
+ description=description,
25
+ examples=examples,
26
+ ).launch()
27
  iface.launch()