OSError: [Errno 22] Invalid argument:
‘M:/ImgSegements/HighResolution\JPEGImages4\S1480009_0|1024_0_1280_1280_0_6016_3384.xml’
Traceback (most recent call last):
File "segment.py", line 300, in <module>
slice_im(List_imgs, outdir, raw_images_dir, raw_ann_dir, sliceHeight=1280, sliceWidth=1280)
File "segment.py", line 284, in slice_im
make_slice_voc(outpath,exiset_obj_list,sliceHeight,sliceWidth)
File "segment.py", line 166, in make_slice_voc
with codecs.open(os.path.join(slice_voc_dir, name[:-4] + '.xml'), 'w', 'utf-8') as xml:
File "J:\WorkSoft\envs\yolov5_test\lib\codecs.py", line 904, in open
file = builtins.open(filename, mode, buffering)
OSError: [Errno 22] Invalid argument: 'M:/ImgSegements/HighResolution\\JPEGImages4\\S1480009_0|1024_0_1280_1280_0_6016_3384.xml'
从上面的信息上看,报错的地方在segment.py 中166行:
with codecs.open(os.path.join(slice_voc_dir, name[:-4] + '.xml'), 'w', 'utf-8') as xml:
也就是打开M:/ImgSegements/HighResolution\\JPEGImages4\\S1480009_0|1024_0_1280_1280_0_6016_3384.xml
这里报错。
需要将 \\ 改成/
将路径统一:M:/ImgSegements/HighResolution/JPEGImages4/S1480009_0|1024_0_1280_1280_0_6016_3384.xml
即可。