Skip to content

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

Bases: Model

Interface for Baidu's RT-DETR model. This Vision Transformer-based object detector 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. Defaults to 'rtdetr-l.pt'.

Source code in ultralytics/models/rtdetr/model.py
class RTDETR(Model):
    """
    Interface for Baidu's RT-DETR model. This Vision Transformer-based object detector provides real-time performance
    with high accuracy. It supports efficient hybrid encoding, IoU-aware query selection, and adaptable inference speed.

    Attributes:
        model (str): Path to the pre-trained model. Defaults to 'rtdetr-l.pt'.
    """

    def __init__(self, model="rtdetr-l.pt") -> None:
        """
        Initializes the RT-DETR model with the given pre-trained model file. Supports .pt and .yaml formats.

        Args:
            model (str): Path to the pre-trained model. Defaults to 'rtdetr-l.pt'.

        Raises:
            NotImplementedError: If the model file extension is not 'pt', 'yaml', or 'yml'.
        """
        super().__init__(model=model, task="detect")

    @property
    def task_map(self) -> dict:
        """
        Returns a task map for RT-DETR, associating tasks with corresponding Ultralytics classes.

        Returns:
            dict: A dictionary mapping task names to Ultralytics task classes for the RT-DETR model.
        """
        return {
            "detect": {
                "predictor": RTDETRPredictor,
                "validator": RTDETRValidator,
                "trainer": RTDETRTrainer,
                "model": RTDETRDetectionModel,
            }
        }

task_map: dict property

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

Returns:

Name Type Description
dict dict

A dictionary mapping task names to Ultralytics task classes for the RT-DETR model.

__init__(model='rtdetr-l.pt')

Initializes the RT-DETR model with the given pre-trained model file. Supports .pt and .yaml formats.

Parameters:

Name Type Description Default
model str

Path to the pre-trained model. Defaults to 'rtdetr-l.pt'.

'rtdetr-l.pt'

Raises:

Type Description
NotImplementedError

If the model file extension is not 'pt', 'yaml', or 'yml'.

Source code in ultralytics/models/rtdetr/model.py
def __init__(self, model="rtdetr-l.pt") -> None:
    """
    Initializes the RT-DETR model with the given pre-trained model file. Supports .pt and .yaml formats.

    Args:
        model (str): Path to the pre-trained model. Defaults to 'rtdetr-l.pt'.

    Raises:
        NotImplementedError: If the model file extension is not 'pt', 'yaml', or 'yml'.
    """
    super().__init__(model=model, task="detect")





Created 2023-11-12, Updated 2023-11-25
Authors: glenn-jocher (3)