Spaces:
Sleeping
Sleeping
Hanqi Xiao
commited on
Commit
·
592f9c7
1
Parent(s):
a7d5c64
deploy to huggingface spaces
Browse files- licensed-image.jpeg +0 -0
- main.py +21 -0
- petClassify.pkl +3 -0
- requirements.txt +2 -0
licensed-image.jpeg
ADDED
main.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
learn = load_learner('petClassify.pkl')
|
4 |
+
labels = learn.dls.vocab
|
5 |
+
def predict(img):
|
6 |
+
img = PILImage.create(img)
|
7 |
+
pred, idx, probs = learn.predict(img)
|
8 |
+
return {labels[i] : float(probs[i]) for i in range(len(labels))}
|
9 |
+
|
10 |
+
|
11 |
+
# print(predict('licensed-image.jpeg'))
|
12 |
+
title = "Pet classifier"
|
13 |
+
description = "Oxford pets classifier based on fine tuned resnet 50"
|
14 |
+
article = "Plaintext"
|
15 |
+
enable_queue = True
|
16 |
+
interpretation= 'default'
|
17 |
+
examples = ['licensed-image.jpeg']
|
18 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3),
|
19 |
+
description=description, title=title, article=article, enable_queue = enable_queue,
|
20 |
+
examples=examples, interpretation=interpretation
|
21 |
+
).launch(share=True)
|
petClassify.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:45e6dd07076c0a28afbb8c3c3bcf2af8b3b265398b3bd524a118c99c3ce50f5d
|
3 |
+
size 103054845
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|