─░├žeri─če ge├ž

Referans i├žin ultralytics/models/nas/model.py

Not

Bu dosya https://github.com/ultralytics/ultralytics/blob/main/ ultralytics/models/nas/model .py adresinde mevcuttur. Bir sorun tespit ederseniz l├╝tfen bir ├çekme ─░ste─či ­čŤá´ŞĆ ile katk─▒da bulunarak d├╝zeltilmesine yard─▒mc─▒ olun. Te┼čekk├╝rler ­čÖĆ!



ultralytics.models.nas.model.NAS

├ťsler: Model

YOLO Nesne alg─▒lama i├žin NAS modeli.

Bu s─▒n─▒f YOLO-NAS modelleri i├žin bir aray├╝z sa─člar ve Model Ultralytics motorundan s─▒n─▒f. ├ľnceden e─čitilmi┼č veya ├Âzel olarak e─čitilmi┼č YOLO-NAS modellerini kullanarak nesne alg─▒lama g├Ârevini kolayla┼čt─▒rmak i├žin tasarlanm─▒┼čt─▒r.

├ľrnek
from ultralytics import NAS

model = NAS('yolo_nas_s')
results = model.predict('ultralytics/assets/bus.jpg')

Nitelikler:

─░sim Tip A├ž─▒klama
model str

├ľnceden e─čitilmi┼č modelin yolu veya model ad─▒. Varsay─▒lan de─čer 'yolo_nas_s.pt' ┼čeklindedir.

Not

YOLO-NAS modelleri yaln─▒zca ├Ânceden e─čitilmi┼č modelleri destekler. YAML yap─▒land─▒rma dosyalar─▒ sa─člamay─▒n.

Kaynak kodu ultralytics/models/nas/model.py
class NAS(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.

    Example:
        ```python
        from ultralytics import NAS

        model = NAS('yolo_nas_s')
        results = model.predict('ultralytics/assets/bus.jpg')
        ```

    Attributes:
        model (str): Path to the pre-trained model or model name. Defaults to 'yolo_nas_s.pt'.

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

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

    @smart_inference_mode()
    def _load(self, weights: str, task: str):
        """Loads an existing NAS model weights or creates a new NAS model with pretrained weights if not provided."""
        import super_gradients

        suffix = Path(weights).suffix
        if suffix == ".pt":
            self.model = torch.load(weights)
        elif suffix == "":
            self.model = super_gradients.training.models.get(weights, pretrained_weights="coco")
        # Standardize model
        self.model.fuse = lambda verbose=True: self.model
        self.model.stride = torch.tensor([32])
        self.model.names = dict(enumerate(self.model._class_names))
        self.model.is_fused = lambda: False  # for info()
        self.model.yaml = {}  # for info()
        self.model.pt_path = weights  # for export()
        self.model.task = "detect"  # for export()

    def info(self, detailed=False, verbose=True):
        """
        Logs model info.

        Args:
            detailed (bool): Show detailed information about model.
            verbose (bool): Controls verbosity.
        """
        return model_info(self.model, detailed=detailed, verbose=verbose, imgsz=640)

    @property
    def task_map(self):
        """Returns a dictionary mapping tasks to respective predictor and validator classes."""
        return {"detect": {"predictor": NASPredictor, "validator": NASValidator}}

task_map property

G├Ârevleri ilgili tahminci ve do─črulay─▒c─▒ s─▒n─▒flar─▒yla e┼čleyen bir s├Âzl├╝k d├Ând├╝r├╝r.

__init__(model='yolo_nas_s.pt')

NAS modelini sa─članan veya varsay─▒lan 'yolo_nas_s.pt' modeliyle ba┼člat─▒r.

Kaynak kodu ultralytics/models/nas/model.py
def __init__(self, model="yolo_nas_s.pt") -> None:
    """Initializes the NAS model with the provided or default 'yolo_nas_s.pt' model."""
    assert Path(model).suffix not in {".yaml", ".yml"}, "YOLO-NAS models only support pre-trained models."
    super().__init__(model, task="detect")

info(detailed=False, verbose=True)

Model bilgilerini kaydeder.

Parametreler:

─░sim Tip A├ž─▒klama Varsay─▒lan
detailed bool

Model hakk─▒nda ayr─▒nt─▒l─▒ bilgi g├Âsterin.

False
verbose bool

Ayr─▒nt─▒lar─▒ kontrol eder.

True
Kaynak kodu ultralytics/models/nas/model.py
def info(self, detailed=False, verbose=True):
    """
    Logs model info.

    Args:
        detailed (bool): Show detailed information about model.
        verbose (bool): Controls verbosity.
    """
    return model_info(self.model, detailed=detailed, verbose=verbose, imgsz=640)





Created 2023-11-12, Updated 2024-06-02
Authors: glenn-jocher (5), Burhan-Q (1)