Add default meta keys. We set default meta keys including `pad_shape`, `scale_factor` and `img_norm_cfg` to avoid the case where no `Resize`, `Normalize` and `Pad` are implemented during the whole pipeline. Args: results (dict): Result dict contains the
(self, results)
| 281 | return results |
| 282 | |
| 283 | def _add_default_meta_keys(self, results): |
| 284 | """Add default meta keys. |
| 285 | |
| 286 | We set default meta keys including `pad_shape`, `scale_factor` and |
| 287 | `img_norm_cfg` to avoid the case where no `Resize`, `Normalize` and |
| 288 | `Pad` are implemented during the whole pipeline. |
| 289 | |
| 290 | Args: |
| 291 | results (dict): Result dict contains the data to convert. |
| 292 | |
| 293 | Returns: |
| 294 | results (dict): Updated result dict contains the data to convert. |
| 295 | """ |
| 296 | img = results['img'] |
| 297 | results.setdefault('pad_shape', img.shape) |
| 298 | results.setdefault('scale_factor', 1.0) |
| 299 | num_channels = 1 if len(img.shape) < 3 else img.shape[2] |
| 300 | results.setdefault( |
| 301 | 'img_norm_cfg', |
| 302 | dict(mean=np.zeros(num_channels, dtype=np.float32), |
| 303 | std=np.ones(num_channels, dtype=np.float32), |
| 304 | to_rgb=False)) |
| 305 | return results |
| 306 | |
| 307 | def __repr__(self): |
| 308 | return self.__class__.__name__ + \ |