File size: 1,918 Bytes
bc2e3ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: mit
metrics:
- accuracy
---
# πŸ–ΌοΈ Image Multi-Label Safety Classifier  
**Repo:** `abhi099k/image-multi-detect`  
**Framework:** PyTorch + ONNX  
**Task:** Multi-label image content classification  
**Author:** Abhinav  

---

## πŸš€ Overview
This model is a **professional multi-label image classifier** trained to detect multiple safety-related categories simultaneously.  
It is optimized for:

- NSFW / adult content detection  
- Violence  
- Weapons  
- Substance categories (smoking, alcohol, drugs)  
- Sensitive content  
- Hate content  

The model supports **8 independent labels**, using **sigmoid (multi-label)** rather than softmax.

---

## 🧠 Labels

| Index | Label      | Meaning |
|-------|------------|---------|
| 0 | `nsfw`      | Nude/sexual content |
| 1 | `violence`  | Physical harm, fighting, blood |
| 2 | `weapon`    | Guns, knives, explosives |
| 3 | `smoking`   | Cigarettes, vaping, smoking activity |
| 4 | `alcohol`   | Alcoholic drinks or consumption |
| 5 | `drugs`     | Illegal drugs, pills, paraphernalia |
| 6 | `sensitive` | Sensitive contexts (medical, blood, etc.) |
| 7 | `hate`      | Hateful symbols, extremist logos |

---

## πŸ“¦ Files in Repository

| File | Description |
|------|-------------|
| `best.pth` | PyTorch model weights |
| `model.onnx` | ONNX-exported model (recommended for inference) |
| `metrics_test.json` | Evaluation results |
| `history.json` | Training logs |

---

## πŸ”§ Technical Details

### Architecture
- **Backbone:** ResNet-50  
- **Head:** Fully connected layer β†’ 8 logits  
- **Loss:** `BCEWithLogitsLoss`  
- **Optimizer:** AdamW  
- **Mixed precision:** Yes  
- **Balanced sampling:** WeightedRandomSampler  

### Image Size
`224 Γ— 224`

### Training Transformations
- Resize  
- Random crop  
- Horizontal flip  
- Color jitter  
- Normalization  

---

## πŸ“ˆ Performance
Macro-averaged metrics on test set: