Frantz103 commited on
Commit
6691e86
1 Parent(s): 0f5e478

Add application file

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+
4
+ learn_inf = load_learner('DogCat.pkl')
5
+ labels = learn_inf.dls.vocab
6
+
7
+ labels = ['Cat', 'Dog']
8
+
9
+ def predict(img):
10
+ img = PILImage.create(img)
11
+ pred, pred_idx, probs = learn_inf.predict(img)
12
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
+
14
+ title = "Is this image a cat?"
15
+ iface = gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512,512)), outputs=gr.outputs.Label(num_top_classes=2), title=title)
16
+ iface.launch()