Spaces:
Sleeping
Sleeping
Added code to run model on hugging face
Browse files- README.md +3 -3
- app.py +21 -0
- requirements.txt +1 -0
README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
colorFrom: indigo
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.3.1
|
8 |
app_file: app.py
|
1 |
---
|
2 |
+
title: Doo-doo Detective
|
3 |
+
emoji: π
|
4 |
colorFrom: indigo
|
5 |
+
colorTo: red
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.3.1
|
8 |
app_file: app.py
|
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
|
3 |
+
learn = load_learner('poop.pkl')
|
4 |
+
labels = learn.dls.vocab
|
5 |
+
|
6 |
+
def predict(img):
|
7 |
+
img = PILImage.create(img)
|
8 |
+
pred,pred_idx,probs = learn.predict(img)
|
9 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
10 |
+
|
11 |
+
import gradio as gr
|
12 |
+
|
13 |
+
|
14 |
+
# add a title and description
|
15 |
+
title = "Is this a photo of a doing his business? Or just a dog hanging out?"
|
16 |
+
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."
|
17 |
+
|
18 |
+
iface = gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3), title=title, description=desc)
|
19 |
+
|
20 |
+
iface.launch()
|
21 |
+
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
fastai
|