Skip to main content

MAS-DETR

PyPI version License Python Version

MAS-DETR is a state-of-the-art Python library for real-time object detection and segmentation based on DETR (DEtection TRansformer) architecture with ultra-fast inference and lightweight backbones.


🚀 Installation

Install the package via pip or uv:

pip install masdetr

Or using uv:

uv add masdetr

Optional Extras

Install additional capabilities for training, ONNX export, or TensorRT deployment:

# Training support (PyTorch Lightning, COCO eval, PEFT)
pip install "masdetr[train]"

# ONNX export support
pip install "masdetr[onnx]"

# TensorRT deployment support
pip install "masdetr[tensorrt]"

# Full installation
pip install "masdetr[train,onnx,tensorrt]"

⚡ Quick Start

1. Model Initialization & Inference

from masdetr import MASDETRNano, MASDETRSmall, MASDETRMedium, MASDETRLarge

# Option A: Train from scratch (no pretrained weights required)
model = MASDETRNano(pretrain_weights=None)

# Option B: Load from a local PyTorch checkpoint
model = MASDETRSmall.from_checkpoint("path/to/checkpoint.pth")

# Predict on an image file, URL, or PIL Image
results = model.predict("image.jpg")
print(results)

2. Model Training

Train an MAS-DETR model on a custom dataset in COCO format:

from masdetr import MASDETRSmall

model = MASDETRSmall(pretrain_weights=None)

# Train on COCO dataset
model.train(
    dataset_dir="path/to/coco_dataset",
    dataset_file="coco",
    epochs=50,
    batch_size=8,
    lr=1e-4,
)

3. Model Export

Export your trained model to ONNX or TensorRT:

from masdetr import MASDETRNano

model = MASDETRNano(pretrain_weights=None)

# Export to ONNX
model.export("model.onnx", format="onnx")

🛠️ Command Line Interface (CLI)

MAS-DETR includes a full-featured command-line tool:

# View general CLI options
masdetr --help

# Run training via CLI
masdetr train --config config.yaml

# Export model via CLI
masdetr export --model masdetr-nano --format onnx

📑 Model Variants

Variant Backbones Supported Task Support
MASDETRNano Lightweight ViT Object Detection
MASDETRSmall DINOv2 / ViT Object Detection
MASDETRMedium DINOv2 / ViT Object Detection
MASDETRLarge DINOv2 / ViT Object Detection
MASDETRSegNano Lightweight ViT Instance Segmentation
MASDETRSegSmall DINOv2 / ViT Instance Segmentation
MASDETRSegMedium DINOv2 / ViT Instance Segmentation
MASDETRSegLarge DINOv2 / ViT Instance Segmentation

📄 License

This project is licensed under the Apache License 2.0.
Portions of the codebase are derived from RF-DETR by Roboflow, Inc., licensed under Apache 2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

masdetr-0.1.0.tar.gz (413.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

masdetr-0.1.0-py3-none-any.whl (482.6 kB view details)

Uploaded Python 3

File details

Details for the file masdetr-0.1.0.tar.gz.

File metadata

  • Download URL: masdetr-0.1.0.tar.gz
  • Upload date:
  • Size: 413.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for masdetr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d59d977ba556bd0e20939d43bee71782d145a56e4bb66bc8bde9cc306b8b4509
MD5 fb1867da3b2718f0362d6335cc26560d
BLAKE2b-256 f34917b71898b75421076cc09b3cf025eef2a7c148f2275fe043d98a79b5011d

See more details on using hashes here.

File details

Details for the file masdetr-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: masdetr-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 482.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for masdetr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9e0118295e78eb899818692ae0e3af12bed6b631d5376a0289329003a07e772
MD5 aef90634fb208aae48ffaa5bbea58c49
BLAKE2b-256 ed17cdcecbb02155ccaa9d73bfc2bb7e9499474832882382c15bf96086bec941

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.1

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page