ONNX

YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

Fruit Recognition System

ResNet18 + CBAM Attention Β· 20-Class Fruit Classification Β· Test Accuracy: 91.78%

Click here to the repo of Github


Model Architecture

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


Key Techniques

CBAM Attention

Channel + Spatial dual-dimension attention, injected after ResNet Layer2/3/4. Guides the model to focus on fruit regions and suppress background interference.

Two-Stage Progressive Training

  • Phase 1 (10 epochs): Freeze backbone, train CBAM + classifier head (lr=1e-3). Only ~213K trainable parameters.
  • Phase 2 (15 epochs): Unfreeze Layer3/4, differential learning rates (backbone=1e-4, head=5e-4).

CutMix Augmentation

Mixed-sample augmentation with probability 0.5. Forces the model to learn from partial regions, improving generalization.

Class Imbalance Handling

Dual mechanism: weighted random sampling + weighted cross-entropy loss to ensure minority class performance.


20 Fruit Classes

# 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

References

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Papers for RoL1n/20-Fruit_Recognition