Spaces:
Runtime error
Runtime error
Pushing app file, examples & requirements
Browse files- app.py +22 -0
- corgi puppy.jfif +0 -0
- golden retriever puppy.jfif +0 -0
- husky puppy.jfif +0 -0
- puppy.pkl +3 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
import skimage
|
4 |
+
|
5 |
+
learn = load_learner('puppy.pkl')
|
6 |
+
|
7 |
+
labels = learn.dls.vocab
|
8 |
+
|
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 = "Puppy Breed Classifier"
|
15 |
+
description = "A puppy breed classifier trained on a custom dataset from DDG images with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
16 |
+
image = gr.Image(height=215, width=215)
|
17 |
+
label = gr.Label()
|
18 |
+
examples = [['corgi puppy.jfif'], ['golden retriever.jfif'], ['husky bear.jfif']]
|
19 |
+
|
20 |
+
|
21 |
+
intf = gr.Interface(fn=predict, inputs=image, outputs=label, title=title, description=description,examples=examples)
|
22 |
+
intf.launch(inline=False)
|
corgi puppy.jfif
ADDED
Binary file (7.01 kB). View file
|
|
golden retriever puppy.jfif
ADDED
Binary file (14.5 kB). View file
|
|
husky puppy.jfif
ADDED
Binary file (9.3 kB). View file
|
|
puppy.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ef4d12e3ff314d1f0840b46e30673f620e2b466fac88ddde28269031d2dd9bb4
|
3 |
+
size 46973950
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|