Customized dataset #3087
Unanswered
Vish19-code
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
hello,
i am using customized dataset and python tools/create_data.py custom --root-path ./data/custom --out-dir ./data/custom --extra-tag custom
for dataset i am using this https://mmdetection3d.readthedocs.io/en/dev-1.x/advanced_guides/customize_dataset.html for multimodel_3dobject detction
use this for train before that i register in creat_data_py
also add in Custom_converter.py and utils.py but i have a problem can you help me how i have to solve
i will write my file
Copyright (c) OpenMMLab. All rights reserved.
from collections import OrderedDict
from pathlib import Path
import mmcv
import mmengine
import numpy as np
from mmdet3d.structures.ops import box_np_ops
from .custom_data_utils import get_custom_image_info
from mmengine import track_parallel_progress, track_iter_progress, dump, load
kitti_categories = ('Pedestrian', 'Cyclist', 'Car')
def convert_to_custom_info_version2(info):
"""Convert custom dataset info format to a KITTI-like format."""
def _read_imageset_file(path):
with open(path, 'r') as f:
lines = f.readlines()
return [int(line) for line in lines]
class _NumPointsInGTCalculater:
"""Calculate the number of points inside ground truth boxes for the custom dataset.
def _calculate_num_points_in_gt(data_path,
infos,
relative_path,
remove_outside=True,
num_features=4):
"""Calculate number of points inside ground truth boxes for the custom dataset."""
def create_custom_info_file(data_path,
pkl_prefix='custom',
save_path=None,
relative_path=True):
"""Create info file for the custom dataset in KITTI format.
def create_waymo_info_file(data_path,
pkl_prefix='waymo',
save_path=None,
relative_path=True,
max_sweeps=5,
workers=8):
"""Create info file of waymo dataset.
def _create_reduced_point_cloud(data_path,
info_path,
save_path=None,
back=False,
num_features=4,
front_camera_id=0):
"""Create reduced point clouds for given info.
def create_reduced_point_cloud(data_path,
pkl_prefix='custom',
train_info_path=None,
val_info_path=None,
test_info_path=None,
save_path=None,
with_back=False):
"""Create reduced point clouds for training/validation/testing.
def generate_record(ann_rec, x1, y1, x2, y2, sample_data_token, filename):
"""Generate one 2D annotation record given various information on top of
the 2D bounding box coordinates.
and my utils file
from collections import OrderedDict
from concurrent import futures as futures
from os import path as osp
from pathlib import Path
import mmengine
import numpy as np
from PIL import Image
from skimage import io
def get_image_index_str(img_idx, use_prefix_id=False):
if use_prefix_id:
return '{:07d}'.format(img_idx)
else:
return '{:06d}'.format(img_idx)
def get_custom_info_path(idx,
prefix,
sub_folder,
file_tail,
relative_path=True,
exist_check=True):
"""Generate file paths for images, LiDAR, and calibration data."""
img_idx_str = get_image_index_str(idx) + file_tail
prefix = Path(prefix)
file_path = Path(sub_folder) / img_idx_str
def get_image_paths(idx, prefix, relative_path=True, exist_check=True):
"""Get paths for both camera images."""
return {
'image_0': get_custom_info_path(idx, prefix, 'images/images_0', '.png', relative_path, exist_check),
'image_1': get_custom_info_path(idx, prefix, 'images/images_1', '.png', relative_path, exist_check)
}
def get_label_path(idx, prefix, relative_path=True, exist_check=True):
"""Get path for label file (ground truth annotations)."""
return get_custom_info_path(idx, prefix, 'labels', '.txt', relative_path, exist_check)
def get_lidar_path(idx, prefix, relative_path=True, exist_check=True):
"""Get path for LiDAR point cloud file (.bin)."""
return get_custom_info_path(idx, prefix, 'points', '.bin', relative_path, exist_check)
def get_calib_path(idx, prefix, relative_path=True, exist_check=True):
"""Get path for calibration file."""
return get_custom_info_path(idx, prefix, 'calibs', '.txt', relative_path, exist_check)
def get_custom_label_anno(label_path):
"""
Parse annotation file for custom dataset.
def _extend_matrix(mat):
mat = np.concatenate([mat, np.array([[0., 0., 0., 1.]])], axis=0)
return mat
def get_custom_image_info(data_path,
training=True,
label_info=True,
lidar=True,
calib=True,
image_ids=None,
relative_path=True):
"""
Extracts image, LiDAR, and calibration information for the custom dataset.
class customInfoGatherer:
"""
Parallel version of custom dataset information gathering.
def custom_anno_to_label_file(annos, folder):
"""
Convert annotations into label files for your custom dataset.
def add_difficulty_to_annos(info):
"""
Adds difficulty levels based on bounding box size and distance.
def custom_result_line(result_dict, precision=4):
"""
Converts a detection result dictionary into a formatted line for the custom dataset.
Beta Was this translation helpful? Give feedback.
All reactions