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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generating Validation Folder

tom-bu opened this issue · 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))`

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