Spaces:
Sleeping
Sleeping
Feat: starting christmas vision space
Browse files- README.md +1 -1
- app.py +27 -0
- examples/pandoro_01.jpg +0 -0
- examples/pandoro_02.jpg +0 -0
- examples/panettone_01.jpg +0 -0
- examples/panettone_02.jpg +0 -0
- model.pkl +3 -0
- requirements.txt +1 -0
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
title: Christmas Panvision
|
3 |
-
emoji:
|
4 |
colorFrom: yellow
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
|
|
1 |
---
|
2 |
title: Christmas Panvision
|
3 |
+
emoji: 🥂
|
4 |
colorFrom: yellow
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
# To solve problems with pathlib in load_learner
|
3 |
+
import pathlib
|
4 |
+
import platform
|
5 |
+
plt = platform.system()
|
6 |
+
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
|
7 |
+
|
8 |
+
from fastai.vision.all import load_learner, PILImage
|
9 |
+
|
10 |
+
learn = load_learner('model.pkl')
|
11 |
+
labels = learn.dls.vocab
|
12 |
+
def predict(img):
|
13 |
+
img = PILImage.create(img)
|
14 |
+
pred,pred_idx,probs = learn.predict(img)
|
15 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
16 |
+
|
17 |
+
title = "Panettone or Pandoro?"
|
18 |
+
description = "A prototype classifier developed with fastaiwith images from ddg."
|
19 |
+
examples = [r'examples/panettone_01.jpg',
|
20 |
+
r'examples/panettone_02.jpg'
|
21 |
+
r'examples/pandoro_01.jpg'
|
22 |
+
r'examples/pandoro_02.jpg'
|
23 |
+
]
|
24 |
+
|
25 |
+
|
26 |
+
demo = gr.Interface(fn=predict, inputs="image", outputs="label", examples=examples)
|
27 |
+
demo.launch()
|
examples/pandoro_01.jpg
ADDED
examples/pandoro_02.jpg
ADDED
examples/panettone_01.jpg
ADDED
examples/panettone_02.jpg
ADDED
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2cfe7d2639ce7e6fa2605080f4c7ab96977995cd5f97efe747119933452d4e8c
|
3 |
+
size 46967090
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastai==2.7.13
|