PabloG commited on
Commit
c7d7333
1 Parent(s): a20d1d3

Added examples and updated app.py

Browse files
app.py CHANGED
@@ -1,7 +1,21 @@
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello updated " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  iface.launch()
 
1
  import gradio as gr
2
 
 
 
3
 
4
+ learn = load_learner('export.pkl')
5
+ labels = learn.dls.vocab
6
+
7
+
8
+ def predict(img):
9
+ img = PILImage.create(img)
10
+ pred, pred_idx, probs = learn.predict(img)
11
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
12
+
13
+
14
+ title = "Gradio test"
15
+ description = "Quick Fastai classifier for bird/forest."
16
+ examples = ['examples/bird.jpg', 'examples/tree.jpg', 'examples/rainforest.jpg']
17
+ interpretation='default'
18
+ enable_queue=True
19
+
20
+ gr.Interface(fn=predict,inputs=gr.Image(),outputs=gr.Label(num_top_classes=2),title=title,description=description,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
21
  iface.launch()
examples/bird.jpg ADDED
examples/rainforest.jpg ADDED
examples/tree.jpg ADDED
requierements.txt ADDED
File without changes