a
    yf                     @   s:   d dl Z d dlmZ d dlmZ dgZG dd deZdS )    N)DetectionValidator)opsNASValidatorc                   @   s   e Zd ZdZdd ZdS )r   a  
    Ultralytics YOLO NAS Validator for object detection.

    Extends `DetectionValidator` from the Ultralytics models package and is designed to post-process the raw predictions
    generated by YOLO NAS models. It performs non-maximum suppression to remove overlapping and low-confidence boxes,
    ultimately producing the final detections.

    Attributes:
        args (Namespace): Namespace containing various configurations for post-processing, such as confidence and IoU.
        lb (torch.Tensor): Optional tensor for multilabel NMS.

    Example:
        ```python
        from ultralytics import NAS

        model = NAS("yolo_nas_s")
        validator = model.validator
        # Assumes that raw_preds are available
        final_preds = validator.postprocess(raw_preds)
        ```

    Note:
        This class is generally not instantiated directly but is used internally within the `NAS` class.
    c              
   C   sh   t |d d }t||d d fdddd}t j|| jj| jj| j	d| jj
pZ| jj| jjddS )z4Apply Non-maximum suppression to prediction outputs.r         Fg      ?)labelsZmulti_labelZagnosticmax_detZmax_time_img)r   Z	xyxy2xywhtorchcatZpermuteZnon_max_suppressionargsconfZiouZlbZ
single_clsZagnostic_nmsr	   )selfZpreds_inZboxespreds r   V/var/www/html/django/DPS/env/lib/python3.9/site-packages/ultralytics/models/nas/val.pypostprocess%   s    "zNASValidator.postprocessN)__name__
__module____qualname____doc__r   r   r   r   r   r      s   )r
   Zultralytics.models.yolo.detectr   Zultralytics.utilsr   __all__r   r   r   r   r   <module>   s   