Skip to content

Reference for ultralytics/models/yolo/obb/train.py

Note

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


ultralytics.models.yolo.obb.train.OBBTrainer

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

Bases: DetectionTrainer

A class extending the DetectionTrainer class for training based on an Oriented Bounding Box (OBB) model.

Example
from ultralytics.models.yolo.obb import OBBTrainer

args = dict(model="yolov8n-obb.pt", data="dota8.yaml", epochs=3)
trainer = OBBTrainer(overrides=args)
trainer.train()
Source code in 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

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

Return OBBModel initialized with specified config and weights.

Source code in 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

get_validator()

Return an instance of OBBValidator for validation of YOLO model.

Source code in 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))



📅 Created 10 months ago ✏️ Updated 1 month ago