Skip to content

Reference for ultralytics/models/rtdetr/model.py

Improvements

This page is sourced from https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/rtdetr/model.py. Have an improvement or example to add? Open a Pull Request — thank you! 🙏


Summary

class ultralytics.models.rtdetr.model.RTDETR

RTDETR(self, model: str = "rtdetr-l.pt") -> None

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.

Args

NameTypeDescriptionDefault
modelstrPath to the pre-trained model. Supports .pt, .yaml, and .yml formats."rtdetr-l.pt"

Attributes

NameTypeDescription
modelstrPath to the pre-trained model.

Methods

NameDescription
task_mapReturn 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")
Source code in ultralytics/models/rtdetr/model.pyView on GitHub
class RTDETR(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:
        model (str): Path to the pre-trained model.

    Methods:
        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")
    """

    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")


property ultralytics.models.rtdetr.model.RTDETR.task_map

def task_map(self) -> dict

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

Returns

TypeDescription
dictA dictionary mapping task names to Ultralytics task classes for the RT-DETR model.
Source code in ultralytics/models/rtdetr/model.pyView on GitHub
@property
def task_map(self) -> dict:
    """Return 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,
        }
    }





📅 Created 2 years ago ✏️ Updated 4 days ago
glenn-jocherjk4eBurhan-Q