juliami commited on
Commit
29880d7
1 Parent(s): 4318ac7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -4
app.py CHANGED
@@ -1,7 +1,30 @@
 
 
 
 
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', 'demo']
2
+
3
+ # Cell
4
+ from fastai.vision.all import *
5
  import gradio as gr
6
 
 
 
7
 
8
+ learn = load_learner('model.pkl')
9
+
10
+ categories = ('Oslo', 'Warszawa')
11
+
12
+
13
+ def classify_image(img):
14
+ pred,idx,probs = learn.predict(img)
15
+ return dict(zip(categories, map(float,probs)))
16
+
17
+
18
+
19
+ def greet(name, intensity):
20
+ return "Hello " * intensity + name + "!"
21
+
22
+ image = gr.Image()
23
+ label = gr.Label()
24
+
25
+ examples = ['oslo.jpeg', 'warszawa.jpg']
26
+
27
+
28
+ demo = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples);
29
+
30
+ demo.launch()