niclan commited on
Commit
6080939
·
1 Parent(s): 78a3ec1

Let's see how this goes

Browse files
Files changed (2) hide show
  1. app.py +24 -4
  2. requirements.txt +1 -0
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
+ __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
+ # Some magic according to https://forums.fast.ai/t/lesson-2-official-topic/96033/376?page=17
8
+
9
+ import sys
10
+
11
+ # Upload your model
12
+ learn = load_learner('niclangf-bird-labeler.pkl')
13
+
14
+ categories = learn.dls.vocab
15
+
16
+ def classify_image(img):
17
+ pred,idx,probs = learn.predict(img)
18
+ return dict(zip(categories, map(float,probs)))
19
+
20
+ image = gr.Image()
21
+ label = gr.Label()
22
 
23
+ # Upload your own images and link them
24
+ examples = ['basset.jpg']
25
 
26
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
27
+ intf.launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio