§
    —/j„
  ã                   óB   — d dl Z d dlmZ d dlmZ  G d„ de¦  «        ZdS )é    N)ÚDetectionPredictor)Úopsc                   ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )ÚNASPredictoraB  Ultralytics YOLO NAS Predictor for object detection.

    This class extends the DetectionPredictor from Ultralytics engine and is responsible for post-processing the raw
    predictions generated by the YOLO NAS models. It applies operations like non-maximum suppression and scaling the
    bounding boxes to fit the original image dimensions.

    Attributes:
        args (Namespace): Namespace containing various configurations for post-processing including confidence
            threshold, IoU threshold, agnostic NMS flag, maximum detections, and class filtering options.
        model (torch.nn.Module): The YOLO NAS model used for inference.
        batch (list): Batch of inputs for processing.

    Examples:
        >>> from ultralytics import NAS
        >>> model = NAS("yolo_nas_s")
        >>> predictor = model.predictor

        Assume that raw_preds, img, orig_imgs are available
        >>> results = predictor.postprocess(raw_preds, img, orig_imgs)

    Notes:
        Typically, this class is not instantiated directly. It is used internally within the NAS class.
    c                 óú   •— t          j        |d         d         ¦  «        }t          j        ||d         d         fd¦  «                             ddd¦  «        }t          ¦   «                              |||¦  «        S )a  Postprocess NAS model predictions to generate final detection results.

        This method takes raw predictions from a YOLO NAS model, converts bounding box formats, and applies
        post-processing operations to generate the final detection results compatible with Ultralytics result
        visualization and analysis tools.

        Args:
            preds_in (list): Raw predictions from the NAS model, typically containing bounding boxes and class scores.
            img (torch.Tensor): Input image tensor that was fed to the model, with shape (B, C, H, W).
            orig_imgs (list | torch.Tensor | np.ndarray): Original images before preprocessing, used for scaling
                coordinates back to original dimensions.

        Returns:
            (list): List of Results objects containing the processed predictions for each image in the batch.

        Examples:
            >>> predictor = NAS("yolo_nas_s").predictor
            >>> results = predictor.postprocess(raw_preds, img, orig_imgs)
        r   é   éÿÿÿÿé   )r   Ú	xyxy2xywhÚtorchÚcatÚpermuteÚsuperÚpostprocess)ÚselfÚpreds_inÚimgÚ	orig_imgsÚboxesÚpredsÚ	__class__s         €úc/home/longshao/multi-rider-rag/.venv/lib/python3.11/site-packages/ultralytics/models/nas/predict.pyr   zNASPredictor.postprocess"   sh   ø€ õ( ”˜h qœk¨!œnÑ-Ô-ˆÝ”	˜5 (¨1¤+¨a¤.Ð1°2Ñ6Ô6×>Ò>¸qÀ!ÀQÑGÔGˆÝ‰wŒw×"Ò" 5¨#¨yÑ9Ô9Ð9ó    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__classcell__)r   s   @r   r   r   	   sB   ø€ € € € € ðð ð0:ð :ð :ð :ð :ð :ð :ð :ð :r   r   )r   Ú&ultralytics.models.yolo.detect.predictr   Úultralytics.utilsr   r   © r   r   ú<module>r"      si   ðð €€€à EÐ EÐ EÐ EÐ EÐ EØ !Ð !Ð !Ð !Ð !Ð !ð/:ð /:ð /:ð /:ð /:Ð%ñ /:ô /:ð /:ð /:ð /:r   