์ฝ˜ํ…์ธ ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

์ฐธ์กฐ ultralytics/models/yolo/obb/train.py

์ฐธ๊ณ 

์ด ํŒŒ์ผ์€ https://github.com/ultralytics/ ultralytics/blob/main/ ultralytics/models/ yolo/obb/train .py์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฌธ์ œ๋ฅผ ๋ฐœ๊ฒฌํ•˜๋ฉด ํ’€ ๋ฆฌํ€˜์ŠคํŠธ (๐Ÿ› ๏ธ) ๋ฅผ ํ†ตํ•ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋„๋ก ๋„์™€์ฃผ์„ธ์š”. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค ๐Ÿ™!



ultralytics.models.yolo.obb.train.OBBTrainer

๋ฒ ์ด์Šค: DetectionTrainer

OBB(์˜ค๋ฆฌ์—”ํ‹ฐ๋“œ ๋ฐ”์šด๋”ฉ ๋ฐ•์Šค) ๋ชจ๋ธ์— ๊ธฐ๋ฐ˜ํ•œ ํ›ˆ๋ จ์„ ์œ„ํ•ด DetectionTrainer ํด๋ž˜์Šค๋ฅผ ํ™•์žฅํ•œ ํด๋ž˜์Šค์ž…๋‹ˆ๋‹ค.

์˜ˆ
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))





Created 2024-01-05, Updated 2024-06-02
Authors: glenn-jocher (4), sergiuwaxmann (1), Burhan-Q (1)