从VOC数据集中提取部分图片对应的标签文件
import shutil
import os
def main():
path_label = './VOCdevkit/VOC2007/Annotations'
path_object = './mydata/VOC2007/JPEGImages_bus'
type_object = '.xml'
path_output = './mydata/VOC2007/Annotations_ssd'
imagelist = os.listdir(path_object)
labellist = os.listdir(path_label)
for x in imagelist:
temp = x.split(".")[0] + type_object
obj_path = os.path.join(path_label, temp)
new_path = os.path.join(path_output, temp)
if temp in labellist:
print(temp)
shutil.copyfile(obj_path, new_path)
if __name__ == '__main__':
main()