Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified Inference #1045

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2be4a8c
initial commit
glenn-jocher Sep 25, 2020
c9ef269
batch inference update
glenn-jocher Sep 27, 2020
c599075
initial commit
glenn-jocher Sep 25, 2020
68c78a0
batch inference update
glenn-jocher Sep 27, 2020
c8141ba
Merge remote-tracking branch 'origin/simple_inference' into simple_in…
glenn-jocher Oct 10, 2020
623c568
add torch capability
glenn-jocher Oct 10, 2020
097aca2
empty image bug fix
glenn-jocher Oct 10, 2020
9896ce0
comment update
glenn-jocher Oct 10, 2020
11ea358
extract NMS to allow for augment
glenn-jocher Oct 10, 2020
82e865a
update NMS thresholds to CoreML defaults
glenn-jocher Oct 10, 2020
c2403d7
fuse() bug fix
glenn-jocher Oct 10, 2020
d87cf7e
Update requirements.txt coremltools==4.0
glenn-jocher Oct 11, 2020
d45e349
Rearrange export input after checks (#1118)
glenn-jocher Oct 11, 2020
10c85bf
FROM nvcr.io/nvidia/pytorch:20.09-py3
glenn-jocher Oct 11, 2020
0ada058
Generalized regression criterion renaming (#1120)
glenn-jocher Oct 11, 2020
00917a6
update expt name comment and folder parsing for training (#978)
Borda Oct 13, 2020
4346b13
Dataset download bash script updates (#1132)
glenn-jocher Oct 13, 2020
4d3680c
Minor import and spelling updates (#1133)
glenn-jocher Oct 13, 2020
c67e722
fix compatibility for hyper config (#1146)
Borda Oct 15, 2020
fe1d90a
fuse() bug fix
glenn-jocher Oct 10, 2020
70432a5
Update requirements.txt coremltools==4.0
glenn-jocher Oct 11, 2020
e63bf4d
Rearrange export input after checks (#1118)
glenn-jocher Oct 11, 2020
bfa2f89
FROM nvcr.io/nvidia/pytorch:20.09-py3
glenn-jocher Oct 11, 2020
402095a
Generalized regression criterion renaming (#1120)
glenn-jocher Oct 11, 2020
7363872
update expt name comment and folder parsing for training (#978)
Borda Oct 13, 2020
6088171
Dataset download bash script updates (#1132)
glenn-jocher Oct 13, 2020
330bdfb
Minor import and spelling updates (#1133)
glenn-jocher Oct 13, 2020
d7e6f4d
fix compatibility for hyper config (#1146)
Borda Oct 15, 2020
34282b0
update copied attributes
glenn-jocher Oct 15, 2020
8668c2b
optimize imports
glenn-jocher Oct 15, 2020
91a029a
initial commit
glenn-jocher Sep 25, 2020
a34b35b
batch inference update
glenn-jocher Sep 27, 2020
a9db87b
initial commit
glenn-jocher Sep 25, 2020
37a07a2
comment update
glenn-jocher Oct 10, 2020
5159d10
extract NMS to allow for augment
glenn-jocher Oct 10, 2020
0be772e
update NMS thresholds to CoreML defaults
glenn-jocher Oct 10, 2020
8144436
update copied attributes
glenn-jocher Oct 15, 2020
dc53110
optimize imports
glenn-jocher Oct 15, 2020
efa5e3f
Merge remote-tracking branch 'origin/simple_inference' into simple_in…
glenn-jocher Oct 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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 <glenn.jocher@ultralytics.com>
  • Loading branch information
Borda and glenn-jocher committed Oct 15, 2020
commit 73638720ee00c3dff2ae3fc6623e8e710fb8cef4
13 changes: 7 additions & 6 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ def train(hyp, opt, device, tb_writer=None):
results = (0, 0, 0, 0, 0, 0, 0) # P, R, mAP@.5, mAP@.5-.95, 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()
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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}')
10 changes: 7 additions & 3 deletions utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import shutil
import subprocess
import time
import re
from contextlib import contextmanager
from copy import copy
from pathlib import Path
Expand Down Expand Up @@ -952,9 +953,12 @@ def increment_dir(dir, comment=''):
# Increments a directory runs/exp1 --> runs/exp2_comment
n = 0 # number
dir = str(Path(dir)) # os-agnostic
d = sorted(glob.glob(dir + '*')) # directories
if len(d):
n = max([int(x[len(dir):x.rfind('_') if '_' in Path(x).name else None]) for x in d]) + 1 # increment
dirs = sorted(glob.glob(dir + '*')) # directories
if dirs:
matches = [re.search(r"exp(\d+)", d) for d in dirs]
idxs = [int(m.groups()[0]) for m in matches if m]
if idxs:
n = max(idxs) + 1 # increment
return dir + str(n) + ('_' + comment if comment else '')


Expand Down