Skip to content

Register now for

# Reference for `ultralytics/models/nas/model.py`

Note

This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/nas/model.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!

## `` ultralytics.models.nas.model.NAS

    NAS(model: str = 'yolo_nas_s.pt')

Bases: `Model`

YOLO-NAS model for object detection.

This class provides an interface for the YOLO-NAS models and extends the `Model` class from Ultralytics engine. It is designed to facilitate the task of object detection using pre-trained or custom-trained YOLO-NAS models.

Attributes:

Name | Type | Description
--- | --- | ---
`model` | `Module` | The loaded YOLO-NAS model.
`task` | `str` | The task type for the model, defaults to 'detect'.
`predictor` | `NASPredictor` | The predictor instance for making predictions.
`validator` | `NASValidator` | The validator instance for model validation.

Methods:

Name | Description
--- | ---
`info` | Log model information and return model details.

Examples:

    >>> from ultralytics import NAS
    >>> model = NAS("yolo_nas_s")
    >>> results = model.predict("ultralytics/assets/bus.jpg")

Notes

YOLO-NAS models only support pre-trained models. Do not provide YAML configuration files.

Source code in `ultralytics/models/nas/model.py`

    45
    46
    47
    48
    def __init__(self, model: str = "yolo_nas_s.pt") -> None:
        """Initialize the NAS model with the provided or default model."""
        assert Path(model).suffix not in {".yaml", ".yml"}, "YOLO-NAS models only support pre-trained models."
        super().__init__(model, task="detect")

### `` task_map `property`

    task_map: dict[str, dict[str, Any]]

Return a dictionary mapping tasks to respective predictor and validator classes.

### `` info

    info(detailed: bool = False, verbose: bool = True) -> dict[str, Any]

Log model information.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`detailed` | `bool` | Show detailed information about model. | `False`
`verbose` | `bool` | Controls verbosity. | `True`

Returns:

Type | Description
--- | ---
`dict[str, Any]` | Model information dictionary.

Source code in `ultralytics/models/nas/model.py`

    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    def info(self, detailed: bool = False, verbose: bool = True) -> dict[str, Any]:
        """
        Log model information.

        Args:
            detailed (bool): Show detailed information about model.
            verbose (bool): Controls verbosity.

        Returns:
            (dict[str, Any]): Model information dictionary.
        """
        return model_info(self.model, detailed=detailed, verbose=verbose, imgsz=640)

📅 Created 1 year ago ✏️ Updated 1 year ago