embracethesock commited on
Commit
d6d8b22
·
1 Parent(s): f273ad4
Files changed (3) hide show
  1. app.py +16 -9
  2. cat_ex.jpg +0 -0
  3. dog_ex.jpg +0 -0
app.py CHANGED
@@ -1,16 +1,23 @@
1
  import gradio as gr
 
 
2
 
3
- learn = load_learner('cat_or_dog.pkl')
4
 
5
- def predict(image):
6
- img = PILImage.create(image)
 
 
7
  pred,pred_idx,probs = learn.predict(img)
8
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
9
 
10
- gr.Interface(
11
- fn=predict,
12
- inputs=gr.inputs.Image(shape=(512, 512)),
13
- outputs=gr.outputs.Label(num_top_classes=3)
14
- ).launch(share=True)
15
 
16
- demo.launch()
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from fastai.vision.all import *
3
+ import skimage
4
 
5
+ def is_cat(x): return x[0].isupper()
6
 
7
+ learn = load_learner('dog_or_cat.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
+ title = "Is it a Cat?"
15
+ examples = ['cat_ex.jpg', 'dog_ex.jpg']
 
 
 
16
 
17
+ gr.Interface(
18
+ fn=predict,
19
+ inputs=gr.components.Image(height=512, width=512),
20
+ outputs=gr.components.Label(),
21
+ title=title,
22
+ examples=examples,
23
+ ).launch()
cat_ex.jpg ADDED
dog_ex.jpg ADDED