File size: 1,164 Bytes
35201ad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5ec57f6
 
 
dec6d8b
09b9382
 
 
5ec57f6
35201ad
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from fastai.vision.all import *

learn = load_learner('poop.pkl')
labels = learn.dls.vocab

def predict(img):
    img = PILImage.create(img)
    pred,pred_idx,probs = learn.predict(img)
    return {labels[i]: float(probs[i]) for i in range(len(labels))}

import gradio as gr


# add a title and description
title = "Is this a photo of a doing his business? Or just a dog hanging out?"
desc = "My dog Kona has a nasty habit of doing her business in a very particular spot in the upstairs of our house. Using this model, I'll be able to aim a camera at that spot and send a text alert whenever she does this, so I'll have a better chance of correcting the bad behavior in the moment, which is essential to training a dog."


article = "Check out [my blog post](https://currentlyobsessed.com/p/my-first-deep-learning-model-doo-doo-detective) about this project."

examples = ['kona.jpg', 'baddog.jpg', 'kona2.jpg', 'kona3.jpg', 'baddog2.jpg']

enable_queue=True

iface = gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3), title=title, description=desc, examples=examples, article=article)

iface.launch()