
    .h                     f    d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ  G d	 d
e      Zy)ag  
Interface for Baidu's RT-DETR, a Vision Transformer-based real-time object detector.

RT-DETR offers real-time performance and high accuracy, excelling in accelerated backends like CUDA with TensorRT.
It features an efficient hybrid encoder and IoU-aware query selection for enhanced detection accuracy.

References:
    https://arxiv.org/pdf/2304.08069.pdf
    )Model)RTDETRDetectionModel)
TORCH_1_11   )RTDETRPredictor)RTDETRTrainer)RTDETRValidatorc                   D     e Zd ZdZddeddf fdZedefd       Z xZ	S )RTDETRa  
    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")
    modelreturnNc                 B    t         sJ d       t        | 	  |d       y)z
        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.
        zRTDETR requires torch>=1.11detect)r   taskN)r   super__init__)selfr   	__class__s     ]/var/www/html/ai-service/venv/lib/python3.12/site-packages/ultralytics/models/rtdetr/model.pyr   zRTDETR.__init__)   s%     888zu84    c                 4    dt         t        t        t        diS )z
        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.
        r   )	predictor	validatortrainerr   )r   r	   r   r   )r   s    r   task_mapzRTDETR.task_map3   s"     ,,(-	
 	
r   )zrtdetr-l.pt)
__name__
__module____qualname____doc__strr   propertydictr   __classcell__)r   s   @r   r   r      s6    &5c 5d 5 
$ 
 
r   r   N)r   ultralytics.engine.modelr   ultralytics.nn.tasksr   ultralytics.utils.torch_utilsr   predictr   trainr   valr	   r    r   r   <module>r+      s*    + 5 4 $    -
U -
r   