-
-
Save amankharwal/665bda5b1a27febf5f6848aa62616d66 to your computer and use it in GitHub Desktop.
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
source = 'training_images' | |
if True: | |
for fold in [0]: | |
val_index = index[len(index)*fold//5:len(index)*(fold+1)//5] | |
for name,mini in tqdm(df.groupby('image_id')): | |
if name in val_index: | |
path2save = 'val2017/' | |
else: | |
path2save = 'train2017/' | |
if not os.path.exists('/tmp/convertor/fold{}/labels/'.format(fold)+path2save): | |
os.makedirs('/tmp/convertor/fold{}/labels/'.format(fold)+path2save) | |
with open('/tmp/convertor/fold{}/labels/'.format(fold)+path2save+name+".txt", 'w+') as f: | |
row = mini[['classes','x_center','y_center','w','h']].astype(float).values | |
row = row.astype(str) | |
for j in range(len(row)): | |
text = ' '.join(row[j]) | |
f.write(text) | |
f.write("\n") | |
if not os.path.exists('/tmp/convertor/fold{}/images/{}'.format(fold,path2save)): | |
os.makedirs('/tmp/convertor/fold{}/images/{}'.format(fold,path2save)) | |
sh.copy("../input/car-object-detection/data/{}/{}.jpg".format(source,name),'/tmp/convertor/fold{}/images/{}/{}.jpg'.format(fold,path2save,name)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment