用labelimg标了几张图不想标了,所以要将标好的在一堆原始数据图片中找出来,放到另一个文件夹里。
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import os
import shutil
jpgnames=[]#用来保存所有原始图片的名字
xmlnames=[]#用来保存所有标注好xml的名字
rootjpgpth=r"D:\chengxu\readvideo\jpg/"#存放原始图片存放的地方
rootxmlpth=r"D:\chengxu\readvideo\xml/"#存放标注好的xml的地方
dstimgpath=r"D:\chengxu\readvideo\dstimg/"#用来存放在rootjpgpth找到的与rootxmlpth对应的图片
for root,dirs,files in os.walk(rootjpgpth):
for file in files:
jpgnames.append(file[:-4])
for root,dirs,files in os.walk(rootxmlpth):
for file in files:
xmlnames.append(file[:-4])
for name in jpgnames:
if name in xmlnames:
shutil.copy(rootjpgpth+name+'.jpg',dstimgpath+name+'.jpg')