lucasgbezerra commited on
Commit
b48fd51
1 Parent(s): bb23f51

Add app.py

Browse files
Files changed (2) hide show
  1. app.py +21 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+
4
+ learn = load_learner('export.pkl')
5
+ labels = learn.dls.vocab
6
+
7
+ def classify_image(img):
8
+ pred,idx,probs = learn.predict(img)
9
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
10
+
11
+ title = "Planets Classifier"
12
+ examples = ['mars.jpg', 'earth.jpg', 'sun.jpg', 'pluto.jpg']
13
+
14
+ iface = gr.Interface(
15
+ fn=classify_image,
16
+ inputs=gr.inputs.Image(shape=(512, 512)),
17
+ outputs=gr.outputs.Label(num_top_classes=3),
18
+ title=title,
19
+ examples=examples,
20
+ )
21
+ iface.launch(inline=False)
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ fastai