3 main(opt) 4 File ".\train.py", line 529, in main 5 train(opt.hyp, opt, device, callbacks) 6 File ".\train.py", line 112, in train 7 data_dict = data_dict or check_dataset(data) # check if None 8 File "F:\yolov5\yolov5-master\utils\general.py", line 518, in check_dataset 9 data = yaml_load(data) # dictionary 10 File "F:\yolov5\yolov5-master\utils\general.py", line 603, in yaml_load 11 return yaml.safe_load(f) 12 File "D:\minconda\envs\demo_py3.8\lib\site-packages\yaml\__init__.py", line 125, in safe_load 13 return load(stream, SafeLoader) 14 File "D:\minconda\envs\demo_py3.8\lib\site-packages\yaml\__init__.py", line 81, in load 15 return loader.get_single_data() 16 File "D:\minconda\envs\demo_py3.8\lib\site-packages\yaml\constructor.py", line 49, in get_single_data 17 node = self.get_single_node() 18 File "D:\minconda\envs\demo_py3.8\lib\site-packages\yaml\composer.py", line 36, in get_single_node 19 document = self.compose_document() 20 File "D:\minconda\envs\demo_py3.8\lib\site-packages\yaml\composer.py", line 55, in compose_document 21 node = self.compose_node(None, None) 22 File "D:\minconda\envs\demo_py3.8\lib\site-packages\yaml\composer.py", line 84, in compose_node 23 node = self.compose_mapping_node(anchor) 24 File "D:\minconda\envs\demo_py3.8\lib\site-packages\yaml\composer.py", line 127, in compose_mapping_node 25 while not self.check_event(MappingEndEvent): 26 File "D:\minconda\envs\demo_py3.8\lib\site-packages\yaml\parser.py", line 98, in check_event 27 self.current_event = self.state() 28 File "D:\minconda\envs\demo_py3.8\lib\site-packages\yaml\parser.py", line 428, in parse_block_mapping_key 29 if self.check_token(KeyToken): 30 File "D:\minconda\envs\demo_py3.8\lib\site-packages\yaml\scanner.py", line 115, in check_token 31 while self.need_more_tokens(): 32 File "D:\minconda\envs\demo_py3.8\lib\site-packages\yaml\scanner.py", line 152, in need_more_tokens 33 self.stale_possible_simple_keys() 34 File "D:\minconda\envs\demo_py3.8\lib\site-packages\yaml\scanner.py", line 291, in stale_possible_simple_keys 35 raise ScannerError("while scanning a simple key", key.mark, 36 yaml.scanner.ScannerError: while scanning a simple key 37 in ".\data\coco_chv.yaml", line 18, column 1 38 could not find expected ':' 39 in ".\data\coco_chv.yaml", line 22, column 1
时间: 2023-07-21 14:50:08 浏览: 217
根据你提供的信息,这是一个 Python 代码的错误信息,可能是在训练 YOLOv5 目标检测模型时出现的问题。具体来说,这个错误是由于在读取 ".\data\coco_chv.yaml" 文件时,遇到了一个无法识别的字符,导致程序无法解析文件。建议检查该文件内容,特别是第 18 行和第 22 行,看看是否缺少了冒号或其他必要的符号。
相关问题
File "d:\Desktop\毕设所有东西\model\yolov5-6.0\train.py", line 844, in <module> main(opt) File "d:\Desktop\毕设所有东西\model\yolov5-6.0\train.py", line 724, in main train(opt.hyp, opt, device, callbacks) File "d:\Desktop\毕设所有东西\model\yolov5-6.0\train.py", line 131, in train anchors=hyp.get('anchors')).to(device) # create File "d:\Desktop\毕设所有东西\model\yolov5-6.0\models\yolo.py", line 126, in __init__ ch=[ch]) # model, savelist File "d:\Desktop\毕设所有东西\model\yolov5-6.0\models\yolo.py", line 383, in parse_model m_ = nn.Sequential(*[m(*args) for _ in range(n)]) if n > 1 else m(*args) # module TypeError: __init__() takes 2 positional arguments but 3 were given
根据您提供的错误信息,在 "d:\Desktop\毕设所有东西\model\yolov5-6.0\train.py" 文件的第 844 行出现了问题。在这一行中调用了 "main(opt)" 方法。
进一步追踪错误,发现在 "train.py" 文件的第 724 行调用了 "train(opt.hyp, opt, device, callbacks)" 方法。
然后,在 "train.py" 文件的第 131 行,在创建模型实例时,调用了 "__init__()" 方法,并传递了 3 个位置参数,但是该初始化方法只接收了 2 个位置参数。
根据错误信息,问题出现在 "yolo.py" 文件的第 383 行,该行代码中调用了 "__init__()" 方法。
为了解决这个问题,您需要检查 "yolo.py" 文件中的代码,并确保在创建模型实例时,传递正确数量的参数给 "__init__()" 方法。
如果您需要更详细的帮助,请提供更多关于您的代码和问题背景的信息。
Traceback (most recent call last): File "E:\yolov5-master\train.py", line 642, in <module> main(opt) File "E:\yolov5-master\train.py", line 531, in main train(opt.hyp, opt, device, callbacks) File "E:\yolov5-master\train.py", line 286, in train for i, (imgs, targets, paths, _) in pbar: # batch ------------------------------------------------------------- File "F:\conda\envs\yolov5\lib\site-packages\tqdm\std.py", line 1178, in __iter__ for obj in iterable: File "E:\yolov5-master\utils\dataloaders.py", line 172, in __iter__ yield next(self.iterator) File "F:\conda\envs\yolov5\lib\site-packages\torch\utils\data\dataloader.py", line 633, in __next__ data = self._next_data() File "F:\conda\envs\yolov5\lib\site-packages\torch\utils\data\dataloader.py", line 1328, in _next_data idx, data = self._get_data() File "F:\conda\envs\yolov5\lib\site-packages\torch\utils\data\dataloader.py", line 1284, in _get_data success, data = self._try_get_data() File "F:\conda\envs\yolov5\lib\site-packages\torch\utils\data\dataloader.py", line 1145, in _try_get_data raise RuntimeError('DataLoader worker (pid(s) {}) exited unexpectedly'.format(pids_str)) from e RuntimeError: DataLoader worker (pid(s) 19928, 15752) exited unexpectedly.
根据你提供的错误信息,这是在运行YOLOv5的训练脚本时出现的错误。错误信息显示,DataLoader的worker进程出现了异常退出,可能是由于某些原因导致数据加载失败。建议你检查一下数据集是否正确加载,并且文件路径是否正确。此外,你也可以尝试增加num_workers参数的数量来尝试解决问题,例如将其从默认值0增加到2或更多。如果问题仍然存在,你可以尝试使用其他的数据加载器,例如PyTorch的ImageFolder数据加载器,来加载数据集。
阅读全文