Created
March 27, 2022 19:02
-
-
Save ashhadulislam/bc463b67ac3500dc0204b7c2d0ab447b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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