astoken commited on
Commit
9d63140
1 Parent(s): bf6f415

Move hyp and opt yaml save to top of train()

Browse files

Fixes bug where scaled values were saved in hyp.yaml, which would cause continuity issues with --resume

Files changed (1) hide show
  1. train.py +6 -6
train.py CHANGED
@@ -52,6 +52,12 @@ def train(hyp):
52
  best = wdir + 'best.pt'
53
  results_file = log_dir + os.sep + 'results.txt'
54
 
 
 
 
 
 
 
55
  epochs = opt.epochs # 300
56
  batch_size = opt.batch_size # 64
57
  weights = opt.weights # initial training weights
@@ -171,12 +177,6 @@ def train(hyp):
171
  model.class_weights = labels_to_class_weights(dataset.labels, nc).to(device) # attach class weights
172
  model.names = data_dict['names']
173
 
174
- # Save run settings
175
- with open(Path(log_dir) / 'hyp.yaml', 'w') as f:
176
- yaml.dump(hyp, f, sort_keys=False)
177
- with open(Path(log_dir) / 'opt.yaml', 'w') as f:
178
- yaml.dump(vars(opt), f, sort_keys=False)
179
-
180
  # Class frequency
181
  labels = np.concatenate(dataset.labels, 0)
182
  c = torch.tensor(labels[:, 0]) # classes
 
52
  best = wdir + 'best.pt'
53
  results_file = log_dir + os.sep + 'results.txt'
54
 
55
+ # Save run settings
56
+ with open(Path(log_dir) / 'hyp.yaml', 'w') as f:
57
+ yaml.dump(hyp, f, sort_keys=False)
58
+ with open(Path(log_dir) / 'opt.yaml', 'w') as f:
59
+ yaml.dump(vars(opt), f, sort_keys=False)
60
+
61
  epochs = opt.epochs # 300
62
  batch_size = opt.batch_size # 64
63
  weights = opt.weights # initial training weights
 
177
  model.class_weights = labels_to_class_weights(dataset.labels, nc).to(device) # attach class weights
178
  model.names = data_dict['names']
179
 
 
 
 
 
 
 
180
  # Class frequency
181
  labels = np.concatenate(dataset.labels, 0)
182
  c = torch.tensor(labels[:, 0]) # classes