File size: 2,004 Bytes
4ff064e
72dc330
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
86
87
---
license: mit
tags:
  - image-classification
  - pytorch
  - mobilenet
  - fashion
  - abaya
  - thobe
pipeline_tag: image-classification
library_name: pytorch
---

# Abaya & Thobe Image Classifier

A fine-tuned **MobileNetV2** model that classifies garment images as **Abaya** or **Thobe**.

## Model Details

| Property | Value |
|----------|-------|
| Base model | MobileNetV2 (ImageNet pretrained) |
| Task | Binary Image Classification |
| Framework | PyTorch |
| Input size | 224 × 224 RGB |
| Output classes | Abaya, Thobe |

## Architecture

The backbone (MobileNetV2) was frozen. Only the custom classifier head was trained:
```
Dropout(0.3) → Linear(1280 → 128) → ReLU → Dropout(0.2) → Linear(128 → 2)
```

## Training

| Setting | Value |
|---------|-------|
| Epochs | 15 |
| Optimizer | Adam |
| Learning rate | 1e-3 |
| Weight decay | 1e-4 |
| Loss | CrossEntropyLoss |
| Dataset | ~500 crawled garment images (Abaya & Thobe) |

## Labels

| ID | Label |
|----|-------|
| 0  | abaya |
| 1  | thobe |

## Usage
```python
import torch
import torch.nn as nn
import torchvision.models as models
import torchvision.transforms as transforms
from huggingface_hub import hf_hub_download
from PIL import Image

# Load model
weights = hf_hub_download("Resham2987/abaya-and-thobes-classifier", "pytorch_model.bin")

model = models.mobilenet_v2(weights=None)
model.classifier = nn.Sequential(
    nn.Dropout(0.3), nn.Linear(1280, 128),
    nn.ReLU(), nn.Dropout(0.2), nn.Linear(128, 2)
)
model.load_state_dict(torch.load(weights, map_location="cpu"))
model.eval()

# Preprocess
tf = transforms.Compose([
    transforms.Resize((224, 224)),
    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])

# Predict
img = Image.open("your_image.jpg").convert("RGB")
with torch.no_grad():
    probs = torch.softmax(model(tf(img).unsqueeze(0)), dim=1)[0]

labels = ["Abaya", "Thobe"]
print(f"{labels[probs.argmax()]}: {probs.max():.1%} confidence")
```