import json import shutil,os path = r'D:/xiazaiym/yolov7-main/VOCdevkit/VOC2007/Annotations/' #xml和jpg混合文件所在的位置 filelist = os.listdir(path) picturelist=[] #存放图片 for file in filelist: if( ".xml" in file ): #找到xml文件 picture1 = file.split(".",1) #用“.”来分割文件名 picture=picture1[0] #得到文件名 picturelist.append(picture) else: continue for picture in picturelist: shutil.copy(r"D:/xiazaiym/yolov7-main/VOCdevkit/VOC2007/Annotations/"+picture+'.jpg', r"D:/xiazaiym/yolov7-main/VOCdevkit/VOC2007/JPEGImages") # 将path下的xml对应的jpg文件存入另一文件夹(放JPEGImages图片)中
import json import shutil,os path = r'D:/xiazaiym/yolov7-main/VOCdevkit/VOC2007/A/' #xml和jpg混合文件所在的位置 filelist = os.listdir(path) picturelist=[] #存放图片 for file in filelist: if( ".xml" in file ): #找到xml文件 picture1 = file.split(".",1) #用“.”来分割文件名 picture=picture1[0] #得到文件名 picturelist.append(picture) else: continue for picture in picturelist: shutil.copy(r"D:/xiazaiym/yolov7-main/VOCdevkit/VOC2007/A/"+picture+'.xml', r"D:\xiazaiym\yolov7-main\VOCdevkit\VOC2007\Annotations") # 将path下的xml对应的xml文件存入Annotations文件夹中
方便训练