TRI-ML / dd3d

Official PyTorch implementation of DD3D: Is Pseudo-Lidar needed for Monocular 3D Object detection? (ICCV 2021), Dennis Park*, Rares Ambrus*, Vitor Guizilini, Jie Li, and Adrien Gaidon.
MIT License
464 stars 74 forks source link

Generating Validation Folder #42

Open tom-bu opened 1 year ago

tom-bu commented 1 year ago

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 commented 1 year ago

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