Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating Validation Folder #42

Open
tom-bu opened this issue Dec 13, 2022 · 1 comment
Open

Generating Validation Folder #42

tom-bu opened this issue Dec 13, 2022 · 1 comment

Comments

@tom-bu
Copy link

tom-bu commented Dec 13, 2022

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))`

@VishalBalaji321
Copy link

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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants