bobs24's picture
Update README.md
c43a507 verified
---
license: mit
language:
- en
base_model:
- facebook/deit-base-patch16-224
---
# DeiT-Classification-Apparel πŸ·οΈπŸ‘•
_A Deep Learning Model for Apparel Image Classification using DeiT_
## πŸ“ Model Overview
The **DeiT-Classification-Apparel** model is a **Vision Transformer (DeiT)** trained to classify different types of apparel. It leverages **Data-efficient Image Transformers (DeiT)** for improved image recognition with minimal computational resources.
- **Architecture**: Vision Transformer (DeiT)
- **Use Case**: Apparel classification
- **Framework**: PyTorch
- **Model Size**: 343MB
- **Files**:
- `DeiT_Model_Parameter.pth` – Trained model weights
- `label_encoder.pkl` – Label encoder for class mapping
## πŸ“‚ Files and Usage
### 1️⃣ Load the Model
```python
import torch
from torchvision import transforms
from PIL import Image
import pickle
# Load Model
model = torch.load_state_dict(torch.load("DeiT_Model_Parameter.pth", map_location=device))
model.eval()
# Load Label Encoder
with open("label_encoder.pkl", "rb") as f:
label_encoder = pickle.load(f)
```
### 2️⃣ Perform Inference
```python
def predict(image_path):
# Load and preprocess image
image = Image.open(image_path).convert("RGB")
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
])
input_tensor = transform(image).unsqueeze(0)
# Make prediction
with torch.no_grad():
output = model(input_tensor)
predicted_label = output.argmax(1).item()
return label_encoder.inverse_transform([predicted_label])[0]
# Example Usage
image_path = "sample.jpg"
prediction = predict(image_path)
print(f"Predicted Apparel: {prediction}")
```
## πŸ“Œ Applications
βœ… Fashion e-commerce product categorization
βœ… Retail inventory management
βœ… Virtual try-on solutions
βœ… Automated fashion recommendation
## πŸ› οΈ Training Details
- **Dataset**: Custom apparel dataset
- **Optimizer**: Adam
- **Loss Function**: CrossEntropyLoss
- **Hardware Used**: NVIDIA T4 GPU
## πŸ“’ Citation
If you use this model, please cite:
```
@misc{bobs24_deit_classification_2024,
author = {bobs24},
title = {DeiT-Classification-Apparel},
year = {2024},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/bobs24/DeiT-Classification-Apparel}}
}