Zum Inhalt springen

Referenz fĂŒr ultralytics/models/yolo/model.py

Hinweis

Diese Datei ist verfĂŒgbar unter https://github.com/ultralytics/ ultralytics/blob/main/ ultralytics/models/ yolo/model .py. Wenn du ein Problem entdeckst, hilf bitte mit, es zu beheben, indem du einen Pull Request đŸ› ïž einreichst. Vielen Dank 🙏!



ultralytics.models.yolo.model.YOLO

Basen: Model

YOLO (You Only Look Once)-Objekterkennungsmodell.

Quellcode in ultralytics/models/yolo/model.py
class YOLO(Model):
    """YOLO (You Only Look Once) object detection model."""

    def __init__(self, model="yolov8n.pt", task=None, verbose=False):
        """Initialize YOLO model, switching to YOLOWorld if model filename contains '-world'."""
        stem = Path(model).stem  # filename stem without suffix, i.e. "yolov8n"
        if "-world" in stem:
            new_instance = YOLOWorld(model)
            self.__class__ = type(new_instance)
            self.__dict__ = new_instance.__dict__
        else:
            # Continue with default YOLO initialization
            super().__init__(model=model, task=task, verbose=verbose)

    @property
    def task_map(self):
        """Map head to model, trainer, validator, and predictor classes."""
        return {
            "classify": {
                "model": ClassificationModel,
                "trainer": yolo.classify.ClassificationTrainer,
                "validator": yolo.classify.ClassificationValidator,
                "predictor": yolo.classify.ClassificationPredictor,
            },
            "detect": {
                "model": DetectionModel,
                "trainer": yolo.detect.DetectionTrainer,
                "validator": yolo.detect.DetectionValidator,
                "predictor": yolo.detect.DetectionPredictor,
            },
            "segment": {
                "model": SegmentationModel,
                "trainer": yolo.segment.SegmentationTrainer,
                "validator": yolo.segment.SegmentationValidator,
                "predictor": yolo.segment.SegmentationPredictor,
            },
            "pose": {
                "model": PoseModel,
                "trainer": yolo.pose.PoseTrainer,
                "validator": yolo.pose.PoseValidator,
                "predictor": yolo.pose.PosePredictor,
            },
            "obb": {
                "model": OBBModel,
                "trainer": yolo.obb.OBBTrainer,
                "validator": yolo.obb.OBBValidator,
                "predictor": yolo.obb.OBBPredictor,
            },
        }

task_map property

Ordne den Kopf den Klassen Model, Trainer, Validator und PrÀdiktor zu.

__init__(model='yolov8n.pt', task=None, verbose=False)

Initialisiere das Modell YOLO und wechsle zu YOLOWorld, wenn der Dateiname des Modells "-world" enthÀlt.

Quellcode in ultralytics/models/yolo/model.py
def __init__(self, model="yolov8n.pt", task=None, verbose=False):
    """Initialize YOLO model, switching to YOLOWorld if model filename contains '-world'."""
    stem = Path(model).stem  # filename stem without suffix, i.e. "yolov8n"
    if "-world" in stem:
        new_instance = YOLOWorld(model)
        self.__class__ = type(new_instance)
        self.__dict__ = new_instance.__dict__
    else:
        # Continue with default YOLO initialization
        super().__init__(model=model, task=task, verbose=verbose)





Erstellt am 2023-11-12, Aktualisiert am 2023-11-25
Autoren: glenn-jocher (3)