Downloads · 30 days
0
RoL1n/20-Fruit_Recognition
20-Fruit_Recognition is a machine learning model from RoL1n. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
ResNet18 + CBAM Attention · 20-Class Fruit Classification · Test Accuracy: 91.78%
Downloads · 30 days
0
Access
Public
Updated Apr 16, 2026
Repo size
176 MB
Likes
0
Public
Click a slice to open those files.
.pt131 MB · 74%
From the Hugging Face model README
ResNet18 + CBAM Attention · 20-Class Fruit Classification · Test Accuracy: 91.78%
Click here to the repo of Github
Input (224×224 RGB)
│
▼
┌─────────────────────────────────┐
│ ResNet18 Backbone (ImageNet) │
│ ├─ Conv1 + BN + ReLU + MaxPool │
│ ├─ Layer1 (64ch) │
│ ├─ Layer2 (128ch) ──► CBAM(128)│
│ ├─ Layer3 (256ch) ──► CBAM(256)│
│ └─ Layer4 (512ch) ──► CBAM(512)│
│ └─ AdaptiveAvgPool2d(1,1) │
└─────────────────────────────────┘
│ 512-d feature
▼
┌─────────────────────────────────┐
│ Classification Head │
│ Dropout(0.5) │
│ Linear(512→256) + ReLU + BN │
│ Dropout(0.3) │
│ Linear(256→20) │
└─────────────────────────────────┘
│
20-class logits
Total Parameters: ~11.39M
Channel + Spatial dual-dimension attention, injected after ResNet Layer2/3/4. Guides the model to focus on fruit regions and suppress background interference.
Mixed-sample augmentation with probability 0.5. Forces the model to learn from partial regions, improving generalization.
Dual mechanism: weighted random sampling + weighted cross-entropy loss to ensure minority class performance.
| # | Fruit | # | Fruit | # | Fruit | # | Fruit |
|---|---|---|---|---|---|---|---|
| 1 | Apple | 6 | Strawberry | 11 | Jujube | 16 | Papaya |
| 2 | Banana | 7 | Pineapple | 12 | Pear | 17 | Avocado |
| 3 | Orange | 8 | Mango | 13 | Cherry | 18 | Blueberry |
| 4 | Grape | 9 | Lemon | 14 | Coconut | 19 | Cantaloupe |
| 5 | Watermelon | 10 | Kiwi | 15 | Pomegranate | 20 | Dragonfruit |