pets / app.py
Haruka's picture
Upload app.py
f2d0244
#!/usr/bin/env python
# coding: utf-8
# In[5]:
from fastai.vision.all import *
import gradio as gr
def is_cat(x): return x[0].isupper()
# In[6]:
learn = load_learner('petsmodel.pkl')
# In[10]:
cat = ('Dog', 'Cat')
# In[11]:
def classify_image(img):
res, idx, prob = learn.predict(img)
return dict(zip(cat, map(float, prob)))
# In[14]:
image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
photos = ['dog.jpg', 'cat.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=photos)
intf.launch(inline=False)