Skip to content

Instantly share code, notes, and snippets.

@ashhadulislam
Created March 27, 2022 19:02
Show Gist options
  • Save ashhadulislam/bc463b67ac3500dc0204b7c2d0ab447b to your computer and use it in GitHub Desktop.
Save ashhadulislam/bc463b67ac3500dc0204b7c2d0ab447b to your computer and use it in GitHub Desktop.
input_path = Path("data/RoadDamageDataset")
output_path = Path("data/assortedFiles")
try:
if not os.path.exists(output_path):
os.mkdir(output_path)
if not os.path.exists(output_path/'images'):
os.mkdir(output_path/'images')
if not os.path.exists(output_path/'labels'):
os.mkdir(output_path/'labels')
except: raise
for fl in os.listdir(input_path):
if not(fl.startswith(".")):
print("Going for ",fl)
count=0
num_files=len(os.listdir(input_path/fl/'Annotations'))
for f in os.listdir(input_path/fl/'Annotations'):
if not(f.startswith(".")):
img_name = f.split('.')[0] + '.jpg'
shutil.copyfile(input_path/fl/'JPEGImages'/img_name, output_path/'images'/img_name)
shutil.copyfile(input_path/fl/'Annotations'/f, output_path/'labels'/f)
count+=1
if count%500==0:
print(count,"/",num_files,"done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment