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.

Metadata

Release files for masdetr 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for masdetr 0.1.1
File Size Uploaded
masdetr-0.1.1.tar.gz 413.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for masdetr 0.1.1
File Interpreter ABI Platform
masdetr-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 896.5 kB

Release files / masdetr-0.1.1.tar.gz

Download URL masdetr-0.1.1.tar.gz
Size 413.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cf7c6a1198345d72f3cc1875feb70f8dbabf7eb6e0528d5395cc69c00dce6416
BLAKE2b-256 checksum
How to use checksums
47529502ed29429be021d63928437e1f90ee7be06f097f10768cf248e4004064
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / masdetr-0.1.1-py3-none-any.whl

Download URL masdetr-0.1.1-py3-none-any.whl
Size 482.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f7af1231988867727cc433f8d67382d1ed928a71ab9601e410e02583788f41cf
BLAKE2b-256 checksum
How to use checksums
6199e9fbc9dac6bc8920063a0b76eb714a20474ecc8e60e04c8d4fbc05d15b6b
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release 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