Downloads · 30 days
6
4% of all-time downloads
malaika16/bag-classifier-v2
bag-classifier-v2 is a machine learning model from malaika16. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository contains the classification head weights for the Bag Image Classifier, fine-tuned on luxury fashion e-commerce images.
Downloads · 30 days
6
4% of all-time downloads
All-time downloads
144
Public
Parameters
85.8M
2.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors343 MB · 100%
From the Hugging Face model README
This repository contains the classification head weights for the Bag Image Classifier, fine-tuned on luxury fashion e-commerce images.
This is the final classification layer (head) of a Vision Transformer (ViT) model fine-tuned to classify luxury bag images as accept or reject for e-commerce catalog use.
google/vit-base-patch16-224| Label | ID | Meaning |
|---|---|---|
| reject | 0 | Image not suitable for catalog |
| accept | 1 | Image suitable for catalog |
Images labeled as accept include:
Images labeled as reject include:
pip install transformers torch
import torch
from transformers import AutoImageProcessor, AutoModelForImageClassification
# Load base ViT model
model = AutoModelForImageClassification.from_pretrained(
"google/vit-base-patch16-224",
num_labels=2,
id2label={0: "reject", 1: "accept"},
label2id={"reject": 0, "accept": 1},
ignore_mismatched_sizes=True
)
# Load and apply head weights
head_weights = torch.load("head.pt", map_location="cpu")
model.classifier.weight = head_weights["classifier.weight"]
model.classifier.bias = head_weights["classifier.bias"]
model.eval()
print("Model ready!")
from PIL import Image
from transformers import AutoImageProcessor
processor = AutoImageProcessor.from_pretrained("google/vit-base-patch16-224")
# Load your image
image = Image.open("your_bag_image.jpg").convert("RGB")
# Preprocess
inputs = processor(images=image, return_tensors="pt")
# Predict
import torch
with torch.no_grad():
outputs = model(**inputs)
predicted_id = outputs.logits.argmax(-1).item()
label = {0: "reject", 1: "accept"}[predicted_id]
confidence = torch.softmax(outputs.logits, dim=-1).max().item()
print(f"Prediction: {label}")
print(f"Confidence: {confidence:.2%}")
| Parameter | Value |
|---|---|
| Base model | google/vit-base-patch16-224 |
| Epochs | 5 |
| Batch size | 16 |
| Image size | 600x600 (thumbnail) |
| Optimizer | AdamW (default) |
| Test accuracy | 98% |
Private dataset hosted on HuggingFace — malaika16/bag-labels
Contains labeled images from 3 luxury fashion websites with 10 categories collapsed into binary accept/reject labels.