Metadata-Version: 2.5
Name: masdetr
Version: 0.1.1
Summary: MAS-DETR: State-of-the-Art Real-Time Object Detection Library
Project-URL: Homepage, https://github.com/masworld/mas-detr
Project-URL: Repository, https://github.com/masworld/mas-detr
Author-email: MAS World <masworldit@gmail.com>
License: Apache-2.0
License-File: LICENSE
Keywords: MAS-DETR
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: numpy
Requires-Dist: pydantic<3,>=2.0
Requires-Dist: pydeprecate<0.10,>=0.9
Requires-Dist: requests
Requires-Dist: supervision>=0.29.0
Requires-Dist: torch>=2.2.0
Requires-Dist: torchvision>=0.17.0
Requires-Dist: tqdm
Requires-Dist: transformers<6.0.0,>=5.1.0
Provides-Extra: augment
Requires-Dist: albumentations<3.0.0,>=1.4.24; extra == 'augment'
Requires-Dist: kornia<1,>=0.7; extra == 'augment'
Provides-Extra: cli
Requires-Dist: jsonargparse[signatures]>=4.27.7; extra == 'cli'
Provides-Extra: coreml
Requires-Dist: coremltools<10.0,>=8.0; extra == 'coreml'
Provides-Extra: executorch
Requires-Dist: executorch<2.0,>=1.3; (python_version < '3.14') and extra == 'executorch'
Provides-Extra: loggers
Requires-Dist: clearml; extra == 'loggers'
Requires-Dist: mlflow; extra == 'loggers'
Requires-Dist: protobuf>=3.20.0; extra == 'loggers'
Requires-Dist: tensorboard>=2.13.0; extra == 'loggers'
Requires-Dist: wandb; extra == 'loggers'
Provides-Extra: lora
Requires-Dist: peft; extra == 'lora'
Provides-Extra: onnx
Requires-Dist: onnx-graphsurgeon; extra == 'onnx'
Requires-Dist: onnx<2.0,>=1.16.0; extra == 'onnx'
Requires-Dist: onnxruntime; (python_version >= '3.11') and extra == 'onnx'
Requires-Dist: onnxruntime<1.24; (python_version < '3.11') and extra == 'onnx'
Requires-Dist: onnxsim>=0.7.0; extra == 'onnx'
Requires-Dist: polygraphy; extra == 'onnx'
Provides-Extra: tensorrt
Requires-Dist: onnxruntime-gpu; extra == 'tensorrt'
Requires-Dist: polygraphy; extra == 'tensorrt'
Requires-Dist: tensorrt>=8.6.1; extra == 'tensorrt'
Provides-Extra: tensorrt-bench
Requires-Dist: pycuda>=2024.1; extra == 'tensorrt-bench'
Provides-Extra: tflite
Requires-Dist: flatbuffers>=23.5.26; (python_version >= '3.12' and python_version < '3.13') and extra == 'tflite'
Requires-Dist: onnx-graphsurgeon; (python_version >= '3.12' and python_version < '3.13') and extra == 'tflite'
Requires-Dist: onnx2tf<3.0.0,>=2.4.0; (python_version >= '3.12' and python_version < '3.13') and extra == 'tflite'
Requires-Dist: onnx<2.0,>=1.20.0; (python_version >= '3.12' and python_version < '3.13') and extra == 'tflite'
Requires-Dist: onnxsim>=0.7.0; (python_version >= '3.12' and python_version < '3.13') and extra == 'tflite'
Requires-Dist: polygraphy; (python_version >= '3.12' and python_version < '3.13') and extra == 'tflite'
Requires-Dist: tensorflow>=2.16.0; (python_version >= '3.12' and python_version < '3.13') and extra == 'tflite'
Requires-Dist: tf-keras>=2.16.0; (python_version >= '3.12' and python_version < '3.13') and extra == 'tflite'
Provides-Extra: train
Requires-Dist: faster-coco-eval>=1.7.2; extra == 'train'
Requires-Dist: peft; extra == 'train'
Requires-Dist: pycocotools; extra == 'train'
Requires-Dist: pytorch-lightning!=2.6.2,!=2.6.3,<3,>=2.6; extra == 'train'
Requires-Dist: roboflow; extra == 'train'
Requires-Dist: scipy; extra == 'train'
Requires-Dist: torchmetrics[detection]>=1.2; extra == 'train'
Provides-Extra: visual
Requires-Dist: matplotlib; extra == 'visual'
Requires-Dist: pandas; extra == 'visual'
Requires-Dist: seaborn; extra == 'visual'
Description-Content-Type: text/markdown

# MAS-DETR

[![PyPI version](https://badge.fury.io/py/masdetr.svg)](https://badge.fury.io/py/masdetr)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Python Version](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)](https://pypi.org/project/masdetr/)

**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`:

```bash
pip install masdetr
```

Or using `uv`:

```bash
uv add masdetr
```

### Optional Extras

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

```bash
# 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

```python
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:

```python
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:

```python
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:

```bash
# 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](LICENSE).  
Portions of the codebase are derived from RF-DETR by Roboflow, Inc., licensed under Apache 2.0.
