minimal / app.py
Pavan767's picture
deploying cats and dogs
444e7ce
raw
history blame contribute delete
727 Bytes
# -*- coding: utf-8 -*-
"""dogs_cats.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1M-mzhZdFQ2XWBSbLCuKzrmLsm0aLEYxQ
## Gradio Pets
"""
#|export
from fastai.vision.all import *
def is_cat(x): return x[0].isupper()
#|export
learn = load_learner('cat_dog.pkl')
#|export
categories = ('Dog','Cat')
def classify_image(img):
pred,idx,probs=learn.predict(img)
return dict(zip(categories,map(float,probs)))
#|export
import gradio
image = gradio.Image(type='pil')
label = gradio.Label()
examples = ['dog.jpeg','cat.jpeg']
intf = gradio.Interface(fn=classify_image,inputs=image,outputs=label,examples=examples)
intf.launch(inline=False)