diff --git a/models/yolo.py b/models/yolo.py index 3f071db5b..5087a9f73 100644 --- a/models/yolo.py +++ b/models/yolo.py @@ -87,7 +87,7 @@ class Model(nn.Module): else: # is *.yaml import yaml # for torch hub self.yaml_file = Path(cfg).name - with open(cfg) as f: + with open(cfg, errors='ignore') as f: self.yaml = yaml.safe_load(f) # model dict # Define model diff --git a/train.py b/train.py index 28bc74740..257256e85 100644 --- a/train.py +++ b/train.py @@ -72,7 +72,7 @@ def train(hyp, # path/to/hyp.yaml or hyp dictionary # Hyperparameters if isinstance(hyp, str): - with open(hyp) as f: + with open(hyp, errors='ignore') as f: hyp = yaml.safe_load(f) # load hyps dict LOGGER.info(colorstr('hyperparameters: ') + ', '.join(f'{k}={v}' for k, v in hyp.items())) @@ -488,7 +488,7 @@ def main(opt, callbacks=Callbacks()): if opt.resume and not check_wandb_resume(opt) and not opt.evolve: # resume an interrupted run ckpt = opt.resume if isinstance(opt.resume, str) else get_latest_run() # specified or most recent path assert os.path.isfile(ckpt), 'ERROR: --resume checkpoint does not exist' - with open(Path(ckpt).parent.parent / 'opt.yaml') as f: + with open(Path(ckpt).parent.parent / 'opt.yaml', errors='ignore') as f: opt = argparse.Namespace(**yaml.safe_load(f)) # replace opt.cfg, opt.weights, opt.resume = '', ckpt, True # reinstate LOGGER.info(f'Resuming training from {ckpt}') @@ -552,7 +552,7 @@ def main(opt, callbacks=Callbacks()): 'mixup': (1, 0.0, 1.0), # image mixup (probability) 'copy_paste': (1, 0.0, 1.0)} # segment copy-paste (probability) - with open(opt.hyp) as f: + with open(opt.hyp, errors='ignore') as f: hyp = yaml.safe_load(f) # load hyps dict if 'anchors' not in hyp: # anchors commented in hyp.yaml hyp['anchors'] = 3 diff --git a/utils/aws/resume.py b/utils/aws/resume.py index e1a8bd896..b21731c97 100644 --- a/utils/aws/resume.py +++ b/utils/aws/resume.py @@ -21,7 +21,7 @@ for last in path.rglob('*/**/last.pt'): continue # Load opt.yaml - with open(last.parent.parent / 'opt.yaml') as f: + with open(last.parent.parent / 'opt.yaml', errors='ignore') as f: opt = yaml.safe_load(f) # Get device count