def __init__(self,
              img_path,
              min_size,
              max_size,
              scale_factor_init,
              num_samples=-1):
     self.img_path = img_path
     assert mmcv.is_filepath(self.img_path)
     self.load_annotations(min_size, max_size, scale_factor_init)
     self.num_samples = num_samples
Exemple #2
0
 def prepare(self):
     """Prepare for evaluating models with this metric."""
     # if `inception_pkl` is provided, read mean and cov stat
     if self.inception_pkl is not None and mmcv.is_filepath(
             self.inception_pkl):
         with open(self.inception_pkl, 'rb') as f:
             reference = pickle.load(f)
             self.real_mean = reference['mean']
             self.real_cov = reference['cov']
             mmcv.print_log(
                 f'Load reference inception pkl from {self.inception_pkl}',
                 'mmgen')
         self.num_real_feeded = self.num_images
Exemple #3
0
def get_available_scenes(nusc):
    """Get available scenes from the input nuscenes class.

    Given the raw data, get the information of available scenes for
    further info generation.

    Args:
        nusc (class): Dataset class in the nuScenes dataset.

    Returns:
        available_scenes (list[dict]): List of basic information for the
            available scenes.
    """
    available_scenes = []
    print('total scene num: {}'.format(len(nusc.scene)))
    for scene in nusc.scene:
        scene_token = scene['token']
        scene_rec = nusc.get('scene', scene_token)
        sample_rec = nusc.get('sample', scene_rec['first_sample_token'])
        sd_rec = nusc.get('sample_data', sample_rec['data']['LIDAR_TOP'])
        has_more_frames = True
        scene_not_exist = False
        while has_more_frames:
            lidar_path, boxes, _ = nusc.get_sample_data(sd_rec['token'])
            lidar_path = str(lidar_path)
            if os.getcwd() in lidar_path:
                # path from lyftdataset is absolute path
                lidar_path = lidar_path.split(f'{os.getcwd()}/')[-1]
                # relative path
            if not mmcv.is_filepath(lidar_path):
                scene_not_exist = True
                break
            else:
                break
            if not sd_rec['next'] == '':
                sd_rec = nusc.get('sample_data', sd_rec['next'])
            else:
                has_more_frames = False
        if scene_not_exist:
            continue
        available_scenes.append(scene)
    print('exist scene num: {}'.format(len(available_scenes)))
    return available_scenes
Exemple #4
0
def test_is_filepath():
    assert mmcv.is_filepath(__file__)
    assert mmcv.is_filepath('abc')
    assert mmcv.is_filepath(Path('/etc'))
    assert not mmcv.is_filepath(0)