From 536e86394503e7c68e537095cf4153644f784cce Mon Sep 17 00:00:00 2001 From: Matt <48956156+MattVAD@users.noreply.github.com> Date: Tue, 8 Feb 2022 11:37:51 +0100 Subject: [PATCH 1/4] Update train.py As see in #6463, modification on train in evolve process to allow custom save directory. --- train.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/train.py b/train.py index 4a1f8958b874..f0d0dc2a39eb 100644 --- a/train.py +++ b/train.py @@ -474,7 +474,7 @@ def parse_opt(known=False): parser.add_argument('--optimizer', type=str, choices=['SGD', 'Adam', 'AdamW'], default='SGD', help='optimizer') parser.add_argument('--sync-bn', action='store_true', help='use SyncBatchNorm, only available in DDP mode') parser.add_argument('--workers', type=int, default=8, help='max dataloader workers (per RANK in DDP mode)') - parser.add_argument('--project', default=ROOT / 'runs/train', help='save to project/name') + parser.add_argument('--project', help='save to project/name') parser.add_argument('--name', default='exp', help='save to project/name') parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment') parser.add_argument('--quad', action='store_true', help='quad dataloader') @@ -515,7 +515,8 @@ def main(opt, callbacks=Callbacks()): check_file(opt.data), check_yaml(opt.cfg), check_yaml(opt.hyp), str(opt.weights), str(opt.project) # checks assert len(opt.cfg) or len(opt.weights), 'either --cfg or --weights must be specified' if opt.evolve: - opt.project = str(ROOT / 'runs/evolve') + if opt.project=='None': + opt.project = str(ROOT / 'runs/evolve') opt.exist_ok, opt.resume = opt.resume, False # pass resume to exist_ok and disable resume opt.save_dir = str(increment_path(Path(opt.project) / opt.name, exist_ok=opt.exist_ok)) From 5e008741c138a3af2289157cb244276a59f26a74 Mon Sep 17 00:00:00 2001 From: Matt <48956156+MattVAD@users.noreply.github.com> Date: Tue, 8 Feb 2022 14:51:27 +0100 Subject: [PATCH 2/4] fix val --- train.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/train.py b/train.py index f0d0dc2a39eb..75cfe6da0c8c 100644 --- a/train.py +++ b/train.py @@ -474,7 +474,7 @@ def parse_opt(known=False): parser.add_argument('--optimizer', type=str, choices=['SGD', 'Adam', 'AdamW'], default='SGD', help='optimizer') parser.add_argument('--sync-bn', action='store_true', help='use SyncBatchNorm, only available in DDP mode') parser.add_argument('--workers', type=int, default=8, help='max dataloader workers (per RANK in DDP mode)') - parser.add_argument('--project', help='save to project/name') + parser.add_argument('--project', default=ROOT / 'runs/train', help='save to project/name') parser.add_argument('--name', default='exp', help='save to project/name') parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment') parser.add_argument('--quad', action='store_true', help='quad dataloader') @@ -515,7 +515,7 @@ def main(opt, callbacks=Callbacks()): check_file(opt.data), check_yaml(opt.cfg), check_yaml(opt.hyp), str(opt.weights), str(opt.project) # checks assert len(opt.cfg) or len(opt.weights), 'either --cfg or --weights must be specified' if opt.evolve: - if opt.project=='None': + if opt.project==str(ROOT / 'runs/train'): opt.project = str(ROOT / 'runs/evolve') opt.exist_ok, opt.resume = opt.resume, False # pass resume to exist_ok and disable resume opt.save_dir = str(increment_path(Path(opt.project) / opt.name, exist_ok=opt.exist_ok)) From 3ef64339bedee3679392d3b8c4918c917a0a3244 Mon Sep 17 00:00:00 2001 From: Matt <48956156+MattVAD@users.noreply.github.com> Date: Tue, 8 Feb 2022 15:09:08 +0100 Subject: [PATCH 3/4] PEP8 whitespace around operator --- train.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/train.py b/train.py index 75cfe6da0c8c..468fc3d81a02 100644 --- a/train.py +++ b/train.py @@ -515,7 +515,7 @@ def main(opt, callbacks=Callbacks()): check_file(opt.data), check_yaml(opt.cfg), check_yaml(opt.hyp), str(opt.weights), str(opt.project) # checks assert len(opt.cfg) or len(opt.weights), 'either --cfg or --weights must be specified' if opt.evolve: - if opt.project==str(ROOT / 'runs/train'): + if opt.project == str(ROOT / 'runs/train'): opt.project = str(ROOT / 'runs/evolve') opt.exist_ok, opt.resume = opt.resume, False # pass resume to exist_ok and disable resume opt.save_dir = str(increment_path(Path(opt.project) / opt.name, exist_ok=opt.exist_ok)) From 1768c40a52eda80c6a2b61c80f06bb0165617c6f Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 8 Feb 2022 16:10:33 +0100 Subject: [PATCH 4/4] Cleanup --- train.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/train.py b/train.py index 468fc3d81a02..24efefa98653 100644 --- a/train.py +++ b/train.py @@ -515,7 +515,7 @@ def main(opt, callbacks=Callbacks()): check_file(opt.data), check_yaml(opt.cfg), check_yaml(opt.hyp), str(opt.weights), str(opt.project) # checks assert len(opt.cfg) or len(opt.weights), 'either --cfg or --weights must be specified' if opt.evolve: - if opt.project == str(ROOT / 'runs/train'): + if opt.project == str(ROOT / 'runs/train'): # if default project name, rename to runs/evolve opt.project = str(ROOT / 'runs/evolve') opt.exist_ok, opt.resume = opt.resume, False # pass resume to exist_ok and disable resume opt.save_dir = str(increment_path(Path(opt.project) / opt.name, exist_ok=opt.exist_ok))