Fix resume (#138)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Laughing
2023-01-03 21:06:22 +08:00
committed by GitHub
parent 82c849c163
commit 340376f7a6
9 changed files with 55 additions and 26 deletions

View File

@ -1,3 +1,5 @@
from copy import copy
import hydra
import torch
import torch.nn as nn
@ -27,7 +29,7 @@ class SegmentationTrainer(v8.detect.DetectionTrainer):
return v8.segment.SegmentationValidator(self.test_loader,
save_dir=self.save_dir,
logger=self.console,
args=self.args)
args=copy(self.args))
def criterion(self, preds, batch):
if not hasattr(self, 'compute_loss'):

View File

@ -37,10 +37,9 @@ class SegmentationValidator(DetectionValidator):
def init_metrics(self, model):
head = model.model[-1] if self.training else model.model.model[-1]
if self.data:
self.is_coco = self.data.get('val', '').endswith(f'coco{os.sep}val2017.txt') # is COCO dataset
self.class_map = ops.coco80_to_coco91_class() if self.is_coco else list(range(1000))
self.args.save_json |= self.is_coco and not self.training # run on final val if training COCO
self.is_coco = self.data.get('val', '').endswith(f'coco{os.sep}val2017.txt') # is COCO dataset
self.class_map = ops.coco80_to_coco91_class() if self.is_coco else list(range(1000))
self.args.save_json |= self.is_coco and not self.training # run on final val if training COCO
self.nc = head.nc
self.nm = head.nm if hasattr(head, "nm") else 32
self.names = model.names