parneyw commited on
Commit
2fa9af0
·
1 Parent(s): b0e51a7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ import skimage
4
+ def is_cat(x):
5
+ return x[0].isupper()
6
+
7
+ learn = load_learner("model.pkl")
8
+ labels = learn.dls.vocab
9
+ def predict(img):
10
+ img = PILImage.create(img)
11
+ pred, pred_idx, probs = learn.predict(img)
12
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
+
14
+ gr.Interface(
15
+ fn=predict,
16
+ inputs=gr.inputs.Image(shape==(512,512)),
17
+ outputs=gr.outputs.Label(num_top_classes=3),
18
+ title="Is it a cat?",
19
+ description="cat classifier",
20
+ interpretation="default",
21
+ enable_queue=True
22
+ ).launch()