Spaces:
Sleeping
Sleeping
Add luxury bag classifier interface minus model
Browse files- app.py +35 -0
- chanel.jpg +0 -0
- gucci.jpg +0 -0
- requirements.txt +2 -0
- vuitton.jpg +0 -0
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
+
|
5 |
+
learn = load_learner("luxury_bag_model.pkl")
|
6 |
+
|
7 |
+
labels = learn.dls.vocab
|
8 |
+
|
9 |
+
|
10 |
+
def predict(img):
|
11 |
+
img = PILImage.create(img)
|
12 |
+
pred, pred_idx, probs = learn.predict(img)
|
13 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
14 |
+
|
15 |
+
|
16 |
+
title = "Luxury Bag Classifier"
|
17 |
+
description = (
|
18 |
+
"A luxury bag classifier trained on photos of a few brands. Created with resnet18 architecture."
|
19 |
+
)
|
20 |
+
article = "<p style='text-align: center'><a href='https://www.kaggle.com/code/sellde/fastai-chapter-2' target='_blank'>Model Source</a></p>"
|
21 |
+
examples = ["gucci.jpg", "chanel.jpg", "vuitton.jpg"]
|
22 |
+
interpretation = "default"
|
23 |
+
enable_queue = True
|
24 |
+
|
25 |
+
gr.Interface(
|
26 |
+
fn=predict,
|
27 |
+
inputs=gr.inputs.Image(shape=(512, 512)),
|
28 |
+
outputs=gr.outputs.Label(),
|
29 |
+
title=title,
|
30 |
+
description=description,
|
31 |
+
article=article,
|
32 |
+
examples=examples,
|
33 |
+
interpretation=interpretation,
|
34 |
+
enable_queue=enable_queue,
|
35 |
+
).launch()
|
chanel.jpg
ADDED
gucci.jpg
ADDED
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|
vuitton.jpg
ADDED