Created
May 8, 2019 05:20
-
-
Save shaystrong/9b349ec377352fd8d9c641836d3a5686 to your computer and use it in GitHub Desktop.
cleanup images & xml label pairs for object detectors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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