Nanobit glenn-jocher commited on
Commit
7f8471e
1 Parent(s): fd532d9

--notest bug fix (#518)

Browse files

* Fix missing results_file and fi when notest passed

* Update train.py

reverting previous changes and removing functionality from 'if not opt.notest or final_epoch: # Calculate mAP' loop.

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Files changed (1) hide show
  1. train.py +18 -18
train.py CHANGED
@@ -346,24 +346,24 @@ def train(hyp, tb_writer, opt, device):
346
  dataloader=testloader,
347
  save_dir=log_dir)
348
 
349
- # Write
350
- with open(results_file, 'a') as f:
351
- f.write(s + '%10.4g' * 7 % results + '\n') # P, R, mAP, F1, test_losses=(GIoU, obj, cls)
352
- if len(opt.name) and opt.bucket:
353
- os.system('gsutil cp %s gs://%s/results/results%s.txt' % (results_file, opt.bucket, opt.name))
354
-
355
- # Tensorboard
356
- if tb_writer:
357
- tags = ['train/giou_loss', 'train/obj_loss', 'train/cls_loss',
358
- 'metrics/precision', 'metrics/recall', 'metrics/mAP_0.5', 'metrics/mAP_0.5:0.95',
359
- 'val/giou_loss', 'val/obj_loss', 'val/cls_loss']
360
- for x, tag in zip(list(mloss[:-1]) + list(results), tags):
361
- tb_writer.add_scalar(tag, x, epoch)
362
-
363
- # Update best mAP
364
- fi = fitness(np.array(results).reshape(1, -1)) # fitness_i = weighted combination of [P, R, mAP, F1]
365
- if fi > best_fitness:
366
- best_fitness = fi
367
 
368
  # Save model
369
  save = (not opt.nosave) or (final_epoch and not opt.evolve)
 
346
  dataloader=testloader,
347
  save_dir=log_dir)
348
 
349
+ # Write
350
+ with open(results_file, 'a') as f:
351
+ f.write(s + '%10.4g' * 7 % results + '\n') # P, R, mAP, F1, test_losses=(GIoU, obj, cls)
352
+ if len(opt.name) and opt.bucket:
353
+ os.system('gsutil cp %s gs://%s/results/results%s.txt' % (results_file, opt.bucket, opt.name))
354
+
355
+ # Tensorboard
356
+ if tb_writer:
357
+ tags = ['train/giou_loss', 'train/obj_loss', 'train/cls_loss',
358
+ 'metrics/precision', 'metrics/recall', 'metrics/mAP_0.5', 'metrics/mAP_0.5:0.95',
359
+ 'val/giou_loss', 'val/obj_loss', 'val/cls_loss']
360
+ for x, tag in zip(list(mloss[:-1]) + list(results), tags):
361
+ tb_writer.add_scalar(tag, x, epoch)
362
+
363
+ # Update best mAP
364
+ fi = fitness(np.array(results).reshape(1, -1)) # fitness_i = weighted combination of [P, R, mAP, F1]
365
+ if fi > best_fitness:
366
+ best_fitness = fi
367
 
368
  # Save model
369
  save = (not opt.nosave) or (final_epoch and not opt.evolve)