ultralytics 8.0.220 fix UnboundLocalError in tuner.py (#6614)

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Maksym Shamrai 2023-11-29 03:29:15 +02:00 committed by GitHub
parent a5390de2f1
commit 9c6989a1b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license
__version__ = '8.0.219'
__version__ = '8.0.220'
from ultralytics.models import RTDETR, SAM, YOLO
from ultralytics.models.fastsam import FastSAM

View File

@ -175,12 +175,12 @@ class Tuner:
metrics = {}
train_args = {**vars(self.args), **mutated_hyp}
save_dir = get_save_dir(get_cfg(train_args))
weights_dir = save_dir / 'weights'
ckpt_file = weights_dir / ('best.pt' if (weights_dir / 'best.pt').exists() else 'last.pt')
try:
# Train YOLO model with mutated hyperparameters (run in subprocess to avoid dataloader hang)
weights_dir = save_dir / 'weights'
cmd = ['yolo', 'train', *(f'{k}={v}' for k, v in train_args.items())]
assert subprocess.run(cmd, check=True).returncode == 0, 'training failed'
ckpt_file = weights_dir / ('best.pt' if (weights_dir / 'best.pt').exists() else 'last.pt')
metrics = torch.load(ckpt_file)['train_metrics']
except Exception as e: