用yolov5训练自己的数据集时,发生如下错误。
if name == "main":
opt = parse_opt()
main(opt)
else:
opt.data, opt.cfg, opt.hyp, opt.weights, opt.project =
check_file(opt.data), check_yaml(opt.cfg), check_yaml(opt.hyp), str(opt.weights), str(opt.project) # checks
assert len(opt.cfg) or len(opt.weights), 'either --cfg or --weights must be specified'
if opt.evolve:
if opt.project == str(ROOT / 'runs/train'): # if default project name, rename to runs/evolve
opt.project = str(ROOT / 'runs/evolve')
opt.exist_ok, opt.resume = opt.resume, False # pass resume to exist_ok and disable resume
opt.save_dir = str(increment_path(Path(opt.project) / opt.name, exist_ok=opt.exist_ok))
else: # search
files = []
for d in 'data', 'models', 'utils': # search directories
files.extend(glob.glob(str(ROOT / d / '**' / file), recursive=True)) # find file
assert len(files), f'File not found: {file}' # assert file was found
assert len(files) == 1, f"Multiple files match '{file}', specify exact path: {files}" # assert unique
return files[0] # return file
D:\anaconda\envs\pytorch\python.exe D:/yolov5-master/yolov5-master/train.py
github: skipping check (not a git repository), for updates see https://github.com/ultralytics/yolov5
train: weights=yolov5l.pt, cfg=models/yolov5l.yaml, data=D:\yolov5-master\yolov5-master\data\ tomato.yaml, hyp=data\hyps\hyp.scratch-low.yaml, epochs=300, batch_size=8, imgsz=640, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, evolve=None, bucket=, cache=None, image_weights=False, device=, multi_scale=False, single_cls=False, optimizer=SGD, sync_bn=False, workers=8, project=runs\train, name=exp, exist_ok=False, quad=False, cos_lr=False, label_smoothing=0.0, patience=100, freeze=[0], save_period=-1, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest
Traceback (most recent call last):
File "D:/yolov5-master/yolov5-master/train.py", line 643, in
main(opt)
File "D:/yolov5-master/yolov5-master/train.py", line 516, in main
check_file(opt.data), check_yaml(opt.cfg), check_yaml(opt.hyp), str(opt.weights), str(opt.project) # checks
File "D:\yolov5-master\yolov5-master\utils\general.py", line 406, in check_file
assert len(files), f'File not found: {file}' # assert file was found
AssertionError: File not found: D:\yolov5-master\yolov5-master\data\ tomato.yaml
Process finished with exit code 1
无
解决此问题
尝试过把相对路径改成绝对路径,并无效果,依然是以上错误。期待老师给出详细的解决方法。谢谢。
确定路径正确吗,你文件名前面是不是多个空格?
实在不行可以尝试换一个路径
路径改了就行
改成和yolov5同一级开始
比如
train: ..\piecedata\train\images
val: ..\piecedata\valid\images
下面是我的路径结构
-clon