Diego Carpintero commited on
Commit
b32ee1e
1 Parent(s): 0876e38

add app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -4
app.py CHANGED
@@ -1,7 +1,26 @@
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
+ title = "Interstellar Classifier"
5
+ description = "Built for fast.ai 'Practical Deep Learning'"
6
+ examples = "examples"
7
 
8
+ model = load_learner("model/model.pkl")
9
+
10
+
11
+ def predict(img):
12
+ labels = model.dls.vocab
13
+ img = PILImage.create(img)
14
+ pred, pred_idx, probs = model.predict(img)
15
+ return dict(map(labels, map(float, probs)))
16
+
17
+
18
+ demo = gr.Interface(
19
+ fn=predict,
20
+ inputs="image",
21
+ outputs="image",
22
+ examples=examples,
23
+ title=title,
24
+ description=description,
25
+ ).queue(default_concurrency_limit=5)
26
+ demo.launch()