Skip to content

About testing MoME #28

Description

@OpenCvhurricane

I use beamreducing , but map is 0.22 ,I want to know how to test mome
my testpipline

test_pipeline = [
dict(
type='RedirectNuScenesLidarPath',
corrupted_root='/home/projects/mome/data/multicorrupt_nuscenes/beamsreducing/3',
),
dict(
type='LoadPointsFromFile',
coord_type='LIDAR',
load_dim=5,
use_dim=[0, 1, 2, 3, 4],
),
dict(
type='LoadPointsFromMultiSweeps',
sweeps_num=10,
use_dim=[0, 1, 2, 3, 4],
),
dict(type='LoadMultiViewImageFromFiles'),
dict(
type='MultiScaleFlipAug3D',
img_scale=(1333, 800),
pts_scale_ratio=1,
flip=False,
transforms=[
dict(
type='GlobalRotScaleTrans',
rot_range=[0, 0],
scale_ratio_range=[1.0, 1.0],
translation_std=[0, 0, 0]),
dict(type='RandomFlip3D'),
dict(type='ResizeCropFlipImage', data_aug_conf=ida_aug_conf, training=False),
dict(type='NormalizeMultiviewImage', **img_norm_cfg),
dict(type='PadMultiViewImage', size_divisor=32),
dict(
type='DefaultFormatBundle3D',
class_names=class_names,
with_label=False),
dict(type='Collect3D', keys=['points', 'img'])
])
]

@PIPELINES.register_module()
class RedirectNuScenesLidarPath(object):
"""Redirect nuScenes lidar paths to corrupted lidar root."""

def __init__(self, corrupted_root, debug=True):
    self.corrupted_root = corrupted_root
    self.debug = debug

def _normalize_rel_path(self, path):
    """Convert original path to relative path under nuScenes root."""
    path = path.replace('\\', '/')

    # 优先截取 samples/LIDAR_TOP 或 sweeps/LIDAR_TOP 后面的部分
    if 'samples/LIDAR_TOP/' in path:
        idx = path.find('samples/LIDAR_TOP/')
        return path[idx:]
    if 'sweeps/LIDAR_TOP/' in path:
        idx = path.find('sweeps/LIDAR_TOP/')
        return path[idx:]

    # 兼容 './data/nuscenes/xxx'
    prefix = './data/nuscenes/'
    if path.startswith(prefix):
        return path[len(prefix):]

    # 兼容 'data/nuscenes/xxx'
    prefix = 'data/nuscenes/'
    if path.startswith(prefix):
        return path[len(prefix):]

    # 兼容绝对路径里含 /data/nuscenes/
    marker = '/data/nuscenes/'
    if marker in path:
        idx = path.find(marker)
        return path[idx + len(marker):]

    # 如果都不匹配,就原样返回
    return path

def __call__(self, results):
    # keyframe lidar
    if 'pts_filename' in results:
        old_path = results['pts_filename']
        rel_path = self._normalize_rel_path(old_path)
        new_path = os.path.join(self.corrupted_root, rel_path)
        results['pts_filename'] = new_path

        if self.debug:
            print('[Redirect] pts_filename old:', old_path)
            print('[Redirect] pts_filename rel:', rel_path)
            print('[Redirect] pts_filename new:', new_path)

    # sweeps lidar
    if 'sweeps' in results:
        for sweep in results['sweeps']:
            if 'data_path' in sweep:
                old_path = sweep['data_path']
                rel_path = self._normalize_rel_path(old_path)
                new_path = os.path.join(self.corrupted_root, rel_path)
                sweep['data_path'] = new_path

                if self.debug:
                    print('[Redirect] sweep old:', old_path)
                    print('[Redirect] sweep rel:', rel_path)
                    print('[Redirect] sweep new:', new_path)

    return results

def __repr__(self):
    return (f'{self.__class__.__name__}('
            f'corrupted_root={self.corrupted_root}, debug={self.debug})')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions