Skip to content

Commit 4ca4aec

Browse files
authored
Do not save hyp.yaml and opt.yaml on evolve (ultralytics#5775)
* Do not save hyp.yaml and opt.yaml on evolve * Update general.py
1 parent 7a39803 commit 4ca4aec

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

train.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,14 @@ def train(hyp, # path/to/hyp.yaml or hyp dictionary
7676
LOGGER.info(colorstr('hyperparameters: ') + ', '.join(f'{k}={v}' for k, v in hyp.items()))
7777

7878
# Save run settings
79-
with open(save_dir / 'hyp.yaml', 'w') as f:
80-
yaml.safe_dump(hyp, f, sort_keys=False)
81-
with open(save_dir / 'opt.yaml', 'w') as f:
82-
yaml.safe_dump(vars(opt), f, sort_keys=False)
83-
data_dict = None
79+
if not evolve:
80+
with open(save_dir / 'hyp.yaml', 'w') as f:
81+
yaml.safe_dump(hyp, f, sort_keys=False)
82+
with open(save_dir / 'opt.yaml', 'w') as f:
83+
yaml.safe_dump(vars(opt), f, sort_keys=False)
8484

8585
# Loggers
86+
data_dict = None
8687
if RANK in [-1, 0]:
8788
loggers = Loggers(save_dir, weights, opt, hyp, LOGGER) # loggers instance
8889
if loggers.wandb:

utils/general.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ def print_mutation(results, hyp, save_dir, bucket):
777777
i = np.argmax(fitness(data.values[:, :7])) #
778778
f.write('# YOLOv5 Hyperparameter Evolution Results\n' +
779779
f'# Best generation: {i}\n' +
780-
f'# Last generation: {len(data)}\n' +
780+
f'# Last generation: {len(data) - 1}\n' +
781781
'# ' + ', '.join(f'{x.strip():>20s}' for x in keys[:7]) + '\n' +
782782
'# ' + ', '.join(f'{x:>20.5g}' for x in data.values[i, :7]) + '\n\n')
783783
yaml.safe_dump(hyp, f, sort_keys=False)

0 commit comments

Comments
 (0)