-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update expt name comment and folder parsing for training (#978)
* comment * fix parsing * fix evolve * folder * tqdm * Update train.py * Update train.py * reinstate anchors into meta dict anchor evolution is working correctly now * reinstate logger prefer the single line readout for concise logging, which helps simplify notebook and tutorials etc. Co-authored-by: Glenn Jocher <[email protected]>
- Loading branch information
1 parent
0ada058
commit 00917a6
Showing
2 changed files
with
14 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,7 +207,8 @@ def train(hyp, opt, device, tb_writer=None): | |
results = (0, 0, 0, 0, 0, 0, 0) # P, R, [email protected], [email protected], val_loss(box, obj, cls) | ||
scheduler.last_epoch = start_epoch - 1 # do not move | ||
scaler = amp.GradScaler(enabled=cuda) | ||
logger.info('Image sizes %g train, %g test\nUsing %g dataloader workers\nLogging results to %s\n' | ||
logger.info('Image sizes %g train, %g test\n' | ||
'Using %g dataloader workers\nLogging results to %s\n' | ||
'Starting training for %g epochs...' % (imgsz, imgsz_test, dataloader.num_workers, log_dir, epochs)) | ||
for epoch in range(start_epoch, epochs): # epoch ------------------------------------------------------------------ | ||
model.train() | ||
|
@@ -393,7 +394,7 @@ def train(hyp, opt, device, tb_writer=None): | |
parser.add_argument('--bucket', type=str, default='', help='gsutil bucket') | ||
parser.add_argument('--cache-images', action='store_true', help='cache images for faster training') | ||
parser.add_argument('--image-weights', action='store_true', help='use weighted image selection for training') | ||
parser.add_argument('--name', default='', help='renames results.txt to results_name.txt if supplied') | ||
parser.add_argument('--name', default='', help='renames experiment folder exp{N} to exp{N}_{name} if supplied') | ||
parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu') | ||
parser.add_argument('--multi-scale', action='store_true', help='vary img-size +/- 50%%') | ||
parser.add_argument('--single-cls', action='store_true', help='train as single-class dataset') | ||
|
@@ -448,7 +449,7 @@ def train(hyp, opt, device, tb_writer=None): | |
if not opt.evolve: | ||
tb_writer = None | ||
if opt.global_rank in [-1, 0]: | ||
logger.info('Start Tensorboard with "tensorboard --logdir %s", view at http://localhost:6006/' % opt.logdir) | ||
logger.info(f'Start Tensorboard with "tensorboard --logdir {opt.logdir}", view at http://localhost:6006/') | ||
tb_writer = SummaryWriter(log_dir=log_dir) # runs/exp0 | ||
|
||
train(hyp, opt, device, tb_writer) | ||
|
@@ -488,7 +489,7 @@ def train(hyp, opt, device, tb_writer=None): | |
assert opt.local_rank == -1, 'DDP mode not implemented for --evolve' | ||
opt.notest, opt.nosave = True, True # only test/save final epoch | ||
# ei = [isinstance(x, (int, float)) for x in hyp.values()] # evolvable indices | ||
yaml_file = Path('runs/evolve/hyp_evolved.yaml') # save best result here | ||
yaml_file = Path(opt.logdir) / 'evolve' / 'hyp_evolved.yaml' # save best result here | ||
if opt.bucket: | ||
os.system('gsutil cp gs://%s/evolve.txt .' % opt.bucket) # download evolve.txt if exists | ||
|
||
|
@@ -532,5 +533,5 @@ def train(hyp, opt, device, tb_writer=None): | |
|
||
# Plot results | ||
plot_evolution(yaml_file) | ||
print('Hyperparameter evolution complete. Best results saved as: %s\nCommand to train a new model with these ' | ||
'hyperparameters: $ python train.py --hyp %s' % (yaml_file, yaml_file)) | ||
print(f'Hyperparameter evolution complete. Best results saved as: {yaml_file}\n' | ||
f'Command to train a new model with these hyperparameters: $ python train.py --hyp {yaml_file}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters