Skip to content

Register now for

# Reference for `ultralytics/models/rtdetr/model.py`

Note

This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/rtdetr/model.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!

## `` ultralytics.models.rtdetr.model.RTDETR

    RTDETR(model: str = 'rtdetr-l.pt')

Bases: `Model`

Interface for Baidu's RT-DETR model, a Vision Transformer-based real-time object detector.

This model provides real-time performance with high accuracy. It supports efficient hybrid encoding, IoU-aware query selection, and adaptable inference speed.

Attributes:

Name | Type | Description
--- | --- | ---
`model` | `str` | Path to the pre-trained model.

Methods:

Name | Description
--- | ---
`task_map` | Return a task map for RT-DETR, associating tasks with corresponding Ultralytics classes.

Examples:

Initialize RT-DETR with a pre-trained model

    >>> from ultralytics import RTDETR
    >>> model = RTDETR("rtdetr-l.pt")
    >>> results = model("image.jpg")

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`model` | `str` | Path to the pre-trained model. Supports .pt, .yaml, and .yml formats. | `'rtdetr-l.pt'`

Source code in `ultralytics/models/rtdetr/model.py`

    41
    42
    43
    44
    45
    46
    47
    48
    49
    def __init__(self, model: str = "rtdetr-l.pt") -> None:
        """
        Initialize the RT-DETR model with the given pre-trained model file.

        Args:
            model (str): Path to the pre-trained model. Supports .pt, .yaml, and .yml formats.
        """
        assert TORCH_1_11, "RTDETR requires torch>=1.11"
        super().__init__(model=model, task="detect")

### `` task_map `property`

    task_map: dict

Return a task map for RT-DETR, associating tasks with corresponding Ultralytics classes.

Returns:

Type | Description
--- | ---
`dict` | A dictionary mapping task names to Ultralytics task classes for the RT-DETR model.

📅 Created 1 year ago ✏️ Updated 1 year ago