跳至内容

描述:掌握Ultralytics YOLO OBB Trainer:使用定向边框(Oriented Bounding Boxes)训练YOLO 模型的专用工具。具有详细的使用方法、模型初始化和训练过程。 关键字:Ultralytics,YOLO OBB Trainer, 定向包围盒, OBB 模型训练,YOLO 模型训练, 计算机视觉, 深度学习, 机器学习,YOLO 对象检测, 模型初始化,YOLO 训练过程


参考资料 ultralytics/models/yolo/obb/train.py

备注

该文件可在https://github.com/ultralytics/ultralytics/blob/main/ ultralytics/models/ yolo/obb/train .py。如果您发现问题,请通过提交 Pull Request🛠️ 帮助修复。谢谢🙏!



ultralytics.models.yolo.obb.train.OBBTrainer

垒球 DetectionTrainer

扩展了 DetectionTrainer 类,用于基于定向边框(OBB)模型进行训练。

示例
from ultralytics.models.yolo.obb import OBBTrainer

args = dict(model='yolov8n-obb.pt', data='dota8.yaml', epochs=3)
trainer = OBBTrainer(overrides=args)
trainer.train()
源代码 ultralytics/models/yolo/obb/train.py
class OBBTrainer(yolo.detect.DetectionTrainer):
    """
    A class extending the DetectionTrainer class for training based on an Oriented Bounding Box (OBB) model.

    Example:
        ```python
        from ultralytics.models.yolo.obb import OBBTrainer

        args = dict(model='yolov8n-obb.pt', data='dota8.yaml', epochs=3)
        trainer = OBBTrainer(overrides=args)
        trainer.train()
        ```
    """

    def __init__(self, cfg=DEFAULT_CFG, overrides=None, _callbacks=None):
        """Initialize a OBBTrainer object with given arguments."""
        if overrides is None:
            overrides = {}
        overrides["task"] = "obb"
        super().__init__(cfg, overrides, _callbacks)

    def get_model(self, cfg=None, weights=None, verbose=True):
        """Return OBBModel initialized with specified config and weights."""
        model = OBBModel(cfg, ch=3, nc=self.data["nc"], verbose=verbose and RANK == -1)
        if weights:
            model.load(weights)

        return model

    def get_validator(self):
        """Return an instance of OBBValidator for validation of YOLO model."""
        self.loss_names = "box_loss", "cls_loss", "dfl_loss"
        return yolo.obb.OBBValidator(self.test_loader, save_dir=self.save_dir, args=copy(self.args))

__init__(cfg=DEFAULT_CFG, overrides=None, _callbacks=None)

使用给定参数初始化一个 OBBTrainer 对象。

源代码 ultralytics/models/yolo/obb/train.py
def __init__(self, cfg=DEFAULT_CFG, overrides=None, _callbacks=None):
    """Initialize a OBBTrainer object with given arguments."""
    if overrides is None:
        overrides = {}
    overrides["task"] = "obb"
    super().__init__(cfg, overrides, _callbacks)

get_model(cfg=None, weights=None, verbose=True)

返回使用指定配置和权重初始化的 OBBModel。

源代码 ultralytics/models/yolo/obb/train.py
def get_model(self, cfg=None, weights=None, verbose=True):
    """Return OBBModel initialized with specified config and weights."""
    model = OBBModel(cfg, ch=3, nc=self.data["nc"], verbose=verbose and RANK == -1)
    if weights:
        model.load(weights)

    return model

get_validator()

返回用于验证YOLO 模型的 OBBValidator 实例。

源代码 ultralytics/models/yolo/obb/train.py
def get_validator(self):
    """Return an instance of OBBValidator for validation of YOLO model."""
    self.loss_names = "box_loss", "cls_loss", "dfl_loss"
    return yolo.obb.OBBValidator(self.test_loader, save_dir=self.save_dir, args=copy(self.args))





创建于 2024-01-05,更新于 2024-01-12
作者:glenn-jocher(2)