Reference for ultralytics/models/nas/predict.py#
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! 🙏
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
| Name | Type | Description |
|---|---|---|
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.predictorAssume that raw_preds, img, orig_imgs are available
>>> results = predictor.postprocess(raw_preds, img, orig_imgs)Typically, this class is not instantiated directly. It is used internally within the NAS class.
ultralytics/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.
"""