数据集中,图像命名错误。
import os
# 图片所在路径
root_path = "F:\\01-02"
filename_list = os.listdir(root_path)
for filename in filename_list:
if '-' in filename:
src_img_path = os.path.join(os.path.abspath(root_path), filename)
new_img_code = filename.split('-')[2].split('.')[0].zfill(5)
dst_img_path = os.path.join(os.path.abspath(root_path), new_img_code + '.png')
os.rename(src_img_path, dst_img_path)
print('converting %s to %s ...' % (src_img_path, dst_img_path))
处理后