dd3d icon indicating copy to clipboard operation
dd3d copied to clipboard

Generating Validation Folder

Open tom-bu opened this issue 1 year ago • 1 comments

For anyone who had to generate the validation folder, here's what I used.

`import os import shutil

root = '' with open(os.path.join(root, "mv3d_kitti_splits", "val.txt")) as _f: lines = _f.readlines() split = [line.rstrip("\n") for line in lines]

for sub in ['calib', 'image_2', 'label_2']: for file in split: if sub == 'calib' or sub == 'label_2': file += '.txt' else: file += '.png' shutil.copyfile(os.path.join(root, 'training',sub, file), os.path.join(root, 'val',sub,file))`

tom-bu avatar Dec 13 '22 15:12 tom-bu

Hi @tom-bu, thanks for this script. It works perfectly, just a small addition: One must create "val" folder along with sub folders "calib", "image_2", "label_2" before executing your script. Or, you can use the below one with integrated os.makedirs() command:

import os
import shutil

root = ''
os.makedirs(os.path.join(root, "val"))
os.makedirs(os.path.join(root, "val", "calib"))
os.makedirs(os.path.join(root, "val", "image_2"))
os.makedirs(os.path.join(root, "val", "label_2"))

with open(os.path.join(root, "mv3d_kitti_splits", "val.txt")) as _f:
    lines = _f.readlines()
    split = [line.rstrip("\n") for line in lines]

    for sub in ['calib', 'image_2', 'label_2']:
        for file in split:
            if sub == 'calib' or sub == 'label_2':
                file += '.txt'
            else:
                file += '.png'
            shutil.copyfile(os.path.join(root, 'training', sub, file), os.path.join(root, 'val',sub,file))

VishalBalaji321 avatar Mar 30 '23 18:03 VishalBalaji321