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.1.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.1-py3-none-any.whl (482.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: masdetr-0.1.1.tar.gz
  • Upload date:
  • Size: 413.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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.1.tar.gz
Algorithm Hash digest
SHA256 cf7c6a1198345d72f3cc1875feb70f8dbabf7eb6e0528d5395cc69c00dce6416
MD5 8d80c0d65abf6a0f8e2727185a63c496
BLAKE2b-256 47529502ed29429be021d63928437e1f90ee7be06f097f10768cf248e4004064

See more details on using hashes here.

File details

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

File metadata

  • Download URL: masdetr-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 482.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f7af1231988867727cc433f8d67382d1ed928a71ab9601e410e02583788f41cf
MD5 45d235425fca1238b701285c43fd6ff0
BLAKE2b-256 6199e9fbc9dac6bc8920063a0b76eb714a20474ecc8e60e04c8d4fbc05d15b6b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

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