删除VOC数据集,没有对应xml的图片文件
path ="" dirs_img = os.listdir(os.path.join(path, "JPEGImages")) dirs_annotations = os.listdir(os.path.join(path, "annotations")) for item_img in dirs_img: name_img = str(item_img).split(".")[0] isFound = False for item_annotations in dirs_annotations: if name_img in item_annotations: isFound = True if not isFound: os.remove(os.path.join(path, "JPEGImages", item_img))