UnicodeDecodeError: 'gbk' codec can't decode byte 0xaa in position 39: illegal multibyte sequence
cuda=10.2
torch=1.8.0
yolov5.3.0的train.py文件
修改如下:
# TODO: Use DDP logging. Only the first process is allowed to log.
# Save run settings
with open(log_dir / 'hyp.yaml', 'w', encoding='utf-8', errors='ignore') as f:
yaml.dump(hyp, f, sort_keys=False)
with open(log_dir / 'opt.yaml', 'w', encoding='utf-8', errors='ignore') as f:
yaml.dump(vars(opt), f, sort_keys=False)
# Configure
cuda = device.type != 'cpu'
init_seeds(2 + rank)
with open(opt.data, encoding='utf-8', errors='ignore') as f:
data_dict = yaml.load(f, Loader=yaml.FullLoader) # model dict
with torch_distributed_zero_first(rank):
check_dataset(data_dict) # check
train_path = data_dict['train']
test_path = data_dict['val']
nc, names = (1, ['item']) if opt.single_cls else (int(data_dict['nc']), data_dict['names']) # number classes, names
assert len(names) == nc, '%g names found for nc=%g dataset in %s' % (len(names), nc, opt.data) # check
已在with open后添加 , encoding='utf-8', errors='ignore' ,仍报错 UnicodeDecodeError: 'gbk' codec can't decode byte 0xaa in position 39: illegal multibyte sequence
报错如下:
试了将.yaml中的空格和换行符删除的方法,没有效果,求指教。