Skip to content

Instantly share code, notes, and snippets.

@shaystrong
Created May 8, 2019 05:20
Show Gist options
  • Save shaystrong/9b349ec377352fd8d9c641836d3a5686 to your computer and use it in GitHub Desktop.
Save shaystrong/9b349ec377352fd8d9c641836d3a5686 to your computer and use it in GitHub Desktop.
cleanup images & xml label pairs for object detectors
def cleanupPairs(pathh):
import glob
for i in glob.glob(pathh+'JPEGImages/'+'*png'):
filename_split = os.path.splitext(i)
filename_zero, fileext = filename_split
basename = os.path.basename(filename_zero)
if not os.path.isfile(pathh+'Annotations/'+basename+'.xml'):
os.system('rm '+i)
for i in glob.glob(pathh+'Annotations/'+'*xml'):
filename_split = os.path.splitext(i)
filename_zero, fileext = filename_split
basename = os.path.basename(filename_zero)
if not os.path.isfile(pathh+'JPEGImages/'+basename+'.png'):
os.system('rm '+i)
cleanupPairs('VOC1900/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment