File size: 2,366 Bytes
c43a507
 
 
 
 
 
 
6ad7197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---
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}}
}