mirror of
https://github.com/ultralytics/yolov5.git
synced 2025-06-03 14:49:29 +08:00
hyperparameter printout update
This commit is contained in:
parent
0fef3f6678
commit
bf6f41567a
1
test.py
1
test.py
@ -19,7 +19,6 @@ def test(data,
|
||||
dataloader=None,
|
||||
save_dir='',
|
||||
merge=False):
|
||||
|
||||
# Initialize/load model and set device
|
||||
training = model is not None
|
||||
if training: # called by train.py
|
||||
|
9
train.py
9
train.py
@ -20,7 +20,6 @@ except:
|
||||
print('Apex recommended for faster mixed precision training: https://github.com/NVIDIA/apex')
|
||||
mixed_precision = False # not installed
|
||||
|
||||
|
||||
# Hyperparameters
|
||||
hyp = {'optimizer': 'SGD', # ['adam', 'SGD', None] if none, default is SGD
|
||||
'lr0': 0.01, # initial learning rate (SGD=1E-2, Adam=1E-3)
|
||||
@ -44,6 +43,7 @@ hyp = {'optimizer': 'SGD', # ['adam', 'SGD', None] if none, default is SGD
|
||||
|
||||
|
||||
def train(hyp):
|
||||
print(f'Hyperparameters {hyp}')
|
||||
log_dir = tb_writer.log_dir # run directory
|
||||
wdir = str(Path(log_dir) / 'weights') + os.sep # weights directory
|
||||
|
||||
@ -365,7 +365,8 @@ if __name__ == '__main__':
|
||||
parser.add_argument('--batch-size', type=int, default=16)
|
||||
parser.add_argument('--img-size', nargs='+', type=int, default=[640, 640], help='train,test sizes')
|
||||
parser.add_argument('--rect', action='store_true', help='rectangular training')
|
||||
parser.add_argument('--resume', nargs='?', const = 'get_last', default=False, help='resume from given path/to/last.pt, or most recent run if blank.')
|
||||
parser.add_argument('--resume', nargs='?', const='get_last', default=False,
|
||||
help='resume from given path/to/last.pt, or most recent run if blank.')
|
||||
parser.add_argument('--nosave', action='store_true', help='only save final checkpoint')
|
||||
parser.add_argument('--notest', action='store_true', help='only test final epoch')
|
||||
parser.add_argument('--noautoanchor', action='store_true', help='disable autoanchor check')
|
||||
@ -394,14 +395,12 @@ if __name__ == '__main__':
|
||||
|
||||
# Train
|
||||
if not opt.evolve:
|
||||
print('Start Tensorboard with "tensorboard --logdir=runs", view at http://localhost:6006/')
|
||||
tb_writer = SummaryWriter(comment=opt.name)
|
||||
if opt.hyp: # update hyps
|
||||
with open(opt.hyp) as f:
|
||||
hyp.update(yaml.load(f, Loader=yaml.FullLoader))
|
||||
|
||||
print(f'Beginning training with {hyp}\n\n')
|
||||
print('Start Tensorboard with "tensorboard --logdir=runs", view at http://localhost:6006/')
|
||||
|
||||
train(hyp)
|
||||
|
||||
# Evolve hyperparameters (optional)
|
||||
|
@ -1180,7 +1180,8 @@ def plot_results_overlay(start=0, stop=0): # from utils.utils import *; plot_re
|
||||
fig.savefig(f.replace('.txt', '.png'), dpi=200)
|
||||
|
||||
|
||||
def plot_results(start=0, stop=0, bucket='', id=(), labels=(), save_dir= ''): # from utils.utils import *; plot_results()
|
||||
def plot_results(start=0, stop=0, bucket='', id=(), labels=(),
|
||||
save_dir=''): # from utils.utils import *; plot_results()
|
||||
# Plot training 'results*.txt' as seen in https://github.com/ultralytics/yolov5#reproduce-our-training
|
||||
fig, ax = plt.subplots(2, 5, figsize=(12, 6))
|
||||
ax = ax.ravel()
|
||||
|
Loading…
x
Reference in New Issue
Block a user