Ultralytics YOLO27: Join the waitlist.
Get Started

Reference for ultralytics/models/nas/predict.py#

Improvements

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


Summary

Class ultralytics.models.nas.predict.NASPredictor#

NASPredictor()

Bases: DetectionPredictor

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

NameTypeDescription
argsNamespaceNamespace containing various configurations for post-processing including confidence threshold, IoU threshold, agnostic NMS flag, maximum detections, and class filtering options.
modeltorch.nn.ModuleThe YOLO NAS model used for inference.
batchlistBatch of inputs for processing.

Examples

>>> from ultralytics import NAS
>>> model = NAS("yolo_nas_s.pt")
>>> model.predict("ultralytics/assets/bus.jpg")  # creates model.predictor
>>> 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.

GitHubultralytics/models/nas/predict.py
class NASPredictor(DetectionPredictor):
    """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.pt")
        >>> model.predict("ultralytics/assets/bus.jpg")  # creates model.predictor
        >>> 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.
    """