mirror of
https://github.com/ultralytics/yolov5.git
synced 2025-06-03 14:49:29 +08:00
parent
4a025ae97f
commit
c5360f6e70
6
train.py
6
train.py
@ -36,7 +36,7 @@ from utils.autoanchor import check_anchors
|
|||||||
from utils.datasets import create_dataloader
|
from utils.datasets import create_dataloader
|
||||||
from utils.general import labels_to_class_weights, increment_path, labels_to_image_weights, init_seeds, \
|
from utils.general import labels_to_class_weights, increment_path, labels_to_image_weights, init_seeds, \
|
||||||
strip_optimizer, get_latest_run, check_dataset, check_git_status, check_img_size, check_requirements, \
|
strip_optimizer, get_latest_run, check_dataset, check_git_status, check_img_size, check_requirements, \
|
||||||
check_yaml, check_suffix, print_mutation, set_logging, one_cycle, colorstr, methods
|
check_file, check_yaml, check_suffix, print_mutation, set_logging, one_cycle, colorstr, methods
|
||||||
from utils.downloads import attempt_download
|
from utils.downloads import attempt_download
|
||||||
from utils.loss import ComputeLoss
|
from utils.loss import ComputeLoss
|
||||||
from utils.plots import plot_labels, plot_evolve
|
from utils.plots import plot_labels, plot_evolve
|
||||||
@ -105,6 +105,7 @@ def train(hyp, # path/to/hyp.yaml or hyp dictionary
|
|||||||
is_coco = data.endswith('coco.yaml') and nc == 80 # COCO dataset
|
is_coco = data.endswith('coco.yaml') and nc == 80 # COCO dataset
|
||||||
|
|
||||||
# Model
|
# Model
|
||||||
|
check_suffix(weights, '.pt') # check weights
|
||||||
pretrained = weights.endswith('.pt')
|
pretrained = weights.endswith('.pt')
|
||||||
if pretrained:
|
if pretrained:
|
||||||
with torch_distributed_zero_first(RANK):
|
with torch_distributed_zero_first(RANK):
|
||||||
@ -484,8 +485,7 @@ def main(opt, callbacks=Callbacks()):
|
|||||||
opt.cfg, opt.weights, opt.resume = '', ckpt, True # reinstate
|
opt.cfg, opt.weights, opt.resume = '', ckpt, True # reinstate
|
||||||
LOGGER.info(f'Resuming training from {ckpt}')
|
LOGGER.info(f'Resuming training from {ckpt}')
|
||||||
else:
|
else:
|
||||||
check_suffix(opt.weights, '.pt') # check weights
|
opt.data, opt.cfg, opt.hyp = check_file(opt.data), check_yaml(opt.cfg), check_yaml(opt.hyp) # check YAMLs
|
||||||
opt.data, opt.cfg, opt.hyp = check_yaml(opt.data), check_yaml(opt.cfg), check_yaml(opt.hyp) # check YAMLs
|
|
||||||
assert len(opt.cfg) or len(opt.weights), 'either --cfg or --weights must be specified'
|
assert len(opt.cfg) or len(opt.weights), 'either --cfg or --weights must be specified'
|
||||||
if opt.evolve:
|
if opt.evolve:
|
||||||
opt.project = 'runs/evolve'
|
opt.project = 'runs/evolve'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user