Spaces:
Runtime error
Runtime error
Commit
·
b898dbc
1
Parent(s):
0dd7ebf
let's deploy to huggingface spaces
Browse files- .ipynb_checkpoints/README-checkpoint.md +13 -0
- .ipynb_checkpoints/app-checkpoint.py +23 -0
- app.py +23 -0
- model.pkl +3 -0
- onions_and_peppers.jpg +0 -0
- pepperoni_and_mushrooms.jpg +0 -0
- requirements.txt +2 -0
.ipynb_checkpoints/README-checkpoint.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Pizza Toppings Classifier
|
3 |
+
emoji: 🐨
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: green
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.12.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: apache-2.0
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
.ipynb_checkpoints/app-checkpoint.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
def get_label(img_path):
|
6 |
+
one_hot = df.query('image_name == @img_path.name').iloc[:, 1:].values[0]
|
7 |
+
return one_hot
|
8 |
+
|
9 |
+
learn = load_learner('model.pkl')
|
10 |
+
|
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 = "Pizza Toppings Classifier"
|
18 |
+
description = "A pizza toppings classifier trained on the MIT pizza dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
19 |
+
examples = ['onions_and_peppers.jpg', 'pepperoni_and_mushrooms.jpg']
|
20 |
+
interpretation='default'
|
21 |
+
enable_queue=True
|
22 |
+
|
23 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=10)).launch(share=True)
|
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
def get_label(img_path):
|
6 |
+
one_hot = df.query('image_name == @img_path.name').iloc[:, 1:].values[0]
|
7 |
+
return one_hot
|
8 |
+
|
9 |
+
learn = load_learner('model.pkl')
|
10 |
+
|
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 = "Pizza Toppings Classifier"
|
18 |
+
description = "A pizza toppings classifier trained on the MIT pizza dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
19 |
+
examples = ['onions_and_peppers.jpg', 'pepperoni_and_mushrooms.jpg']
|
20 |
+
interpretation='default'
|
21 |
+
enable_queue=True
|
22 |
+
|
23 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=10)).launch(share=True)
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a6523948621fe6636566116b10340fba01e39aa364fa7043691a21983093507c
|
3 |
+
size 114761001
|
onions_and_peppers.jpg
ADDED
![]() |
pepperoni_and_mushrooms.jpg
ADDED
![]() |
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|