Skip to content

Lightweight re-implementation of the DeTr algorithm on a small scale dataset PASCAL-VOC

License

Notifications You must be signed in to change notification settings

ilyasoulk/tiny-detr

Repository files navigation

tiny-detr πŸ”

Python 3.8+ License: MIT Code style: black

A lightweight implementation of the DETR (DEtection TRansformer) object detection model, using ResNet-18 as the backbone and a simplified transformer architecture.

DETR Architecture

🌟 Highlights

  • Lightweight: Only ~13.9M parameters (compared to original DETR's 41M+)
  • Fast Training: 2-3x faster training compared to original DETR
  • Simple Architecture: Perfect for learning and experimentation
  • Multi-Dataset Support: Works with COCO and PASCAL VOC

πŸ—οΈ Architecture

Component Specification
Backbone ResNet-18
Transformer Encoder 2 layers, 4 heads
Transformer Decoder 2 layers, 4 heads
Hidden Dimension 128
Object Queries 100

πŸ“ˆ Performance

Metric Value
mAP 17.40
mAP@50 39.14
mAP@75 14.02

πŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/ilyasoulk/tiny-detr.git
cd tiny-detr/src/detr

# Create virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate  # Linux/Mac
# or
.\venv\Scripts\activate  # Windows

# Install dependencies
pip install -r requirements.txt

Training

python src/detr/train.py

Inference

python src/detr/inference.py

πŸ“ Project Structure

src/detr/
β”œβ”€β”€ train.py          # Training script
β”œβ”€β”€ inference.py      # Inference and visualization
β”œβ”€β”€ model.py          # Model architecture
β”œβ”€β”€ loss.py          # Bipartite matching loss
β”œβ”€β”€ metrics.py        # mAP calculation
β”œβ”€β”€ engine.py         # Training and evaluation loops
β”œβ”€β”€ dataset.py        # COCO dataset handling
└── dataset_voc.py    # VOC dataset handling

βš™οΈ Configuration

config = {
    'backbone': 'resnet18',
    'hidden_dim': 128,
    'num_heads': 4,
    'num_encoder': 2,
    'num_decoder': 2,
    'num_queries': 100,
    'learning_rate': 1e-4,
    'weight_decay': 1e-4
}

πŸ“Š Dataset Support

Supported datasets:

  • COCO: Full support with automatic download
  • PASCAL VOC: Full support with automatic download

πŸ™ Acknowledgments

This implementation is inspired by the original DETR paper:

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Lightweight re-implementation of the DeTr algorithm on a small scale dataset PASCAL-VOC

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages