mirror of
https://github.com/THU-MIG/yolov10.git
synced 2025-05-23 05:24:22 +08:00
21 lines
856 B
Python
21 lines
856 B
Python
from ultralytics.models.yolo.detect import DetectionTrainer
|
|
from .val import YOLOv10SegValidator
|
|
from .model import YOLOv10SegmentationModel
|
|
from copy import copy
|
|
from ultralytics.utils import RANK
|
|
|
|
class YOLOv10SegTrainer(DetectionTrainer):
|
|
def get_validator(self):
|
|
"""Returns a DetectionValidator for YOLO model validation."""
|
|
self.loss_names = "box_om", "cls_om", "dfl_om", "box_oo", "cls_oo", "dfl_oo",
|
|
return YOLOv10SegValidator(
|
|
self.test_loader, save_dir=self.save_dir, args=copy(self.args), _callbacks=self.callbacks
|
|
)
|
|
|
|
def get_model(self, cfg=None, weights=None, verbose=True):
|
|
"""Return a YOLO detection model."""
|
|
model = YOLOv10SegmentationModel(cfg, nc=self.data["nc"], verbose=verbose and RANK == -1)
|
|
if weights:
|
|
model.load(weights)
|
|
return model
|