Hannah0911 commited on
Commit
8cbfb64
·
1 Parent(s): ac7f541

Create app.py

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