Multiview data processing pipeline. The transform steps are as follows: 1. Select frames. 2. Re-ororganize the selected data structure. 3. Apply transforms for each selected frame. 4. Concatenate data to form a batch. Args: transforms (list[dict | c
| 8 | |
| 9 | @TRANSFORMS.register_module() |
| 10 | class MultiViewPipeline(BaseTransform): |
| 11 | """Multiview data processing pipeline. |
| 12 | |
| 13 | The transform steps are as follows: |
| 14 | |
| 15 | 1. Select frames. |
| 16 | 2. Re-ororganize the selected data structure. |
| 17 | 3. Apply transforms for each selected frame. |
| 18 | 4. Concatenate data to form a batch. |
| 19 | |
| 20 | Args: |
| 21 | transforms (list[dict | callable]): |
| 22 | The transforms to be applied to each select frame. |
| 23 | n_images (int): Number of frames selected per scene. |
| 24 | ordered (bool): Whether to put these frames in order. |
| 25 | Defaults to False. |
| 26 | """ |
| 27 | |
| 28 | def __init__(self, transforms, n_images, ordered=False): |
| 29 | super().__init__() |
| 30 | self.transforms = Compose(transforms) |
| 31 | self.n_images = n_images |
| 32 | self.ordered = ordered |
| 33 | |
| 34 | def transform(self, results: dict) -> dict: |
| 35 | """Transform function. |
| 36 | |
| 37 | Args: |
| 38 | results (dict): Result dict from loading pipeline. |
| 39 | |
| 40 | Returns: |
| 41 | dict: output dict after transformation. |
| 42 | """ |
| 43 | imgs = [] |
| 44 | img_paths = [] |
| 45 | points = [] |
| 46 | intrinsics = [] |
| 47 | extrinsics = [] |
| 48 | ids = np.arange(len(results['img_path'])) |
| 49 | replace = True if self.n_images > len(ids) else False |
| 50 | if self.ordered: |
| 51 | step = (len(ids) - 1) // (self.n_images - 1 |
| 52 | ) # TODO: BUG, fix from branch fbocc |
| 53 | if step > 0: |
| 54 | ids = ids[::step] |
| 55 | # sometimes can not get the accurate n_images in this way |
| 56 | # then take the first n_images one |
| 57 | ids = ids[:self.n_images] |
| 58 | else: # the number of images < pre-set n_images |
| 59 | # randomly select n_images ids to enable batch-wise inference |
| 60 | # In practice, can directly use the original ids to avoid |
| 61 | # redundant computation |
| 62 | ids = np.random.choice(ids, self.n_images, replace=replace) |
| 63 | else: |
| 64 | ids = np.random.choice(ids, self.n_images, replace=replace) |
| 65 | for i in ids.tolist(): |
| 66 | _results = dict() |
| 67 | _results['img_path'] = results['img_path'][i] |
nothing calls this directly
no outgoing calls
no test coverage detected