Normalize and prepare inputs as a list of tensors. Each tensor correspond to a unique pathway. Args: frames (list of array): list of input images (correspond to one clip) in range [0, 255]. cfg (CfgNode): configs. Details can be found in slowfast/config/defau
(frames, cfg)
| 302 | |
| 303 | |
| 304 | def process_cv2_inputs(frames, cfg): |
| 305 | """ |
| 306 | Normalize and prepare inputs as a list of tensors. Each tensor |
| 307 | correspond to a unique pathway. |
| 308 | Args: |
| 309 | frames (list of array): list of input images (correspond to one clip) in range [0, 255]. |
| 310 | cfg (CfgNode): configs. Details can be found in |
| 311 | slowfast/config/defaults.py |
| 312 | """ |
| 313 | inputs = torch.from_numpy(np.array(frames)).float() / 255 |
| 314 | inputs = tensor_normalize(inputs, cfg.DATA.MEAN, cfg.DATA.STD) |
| 315 | # T H W C -> C T H W. |
| 316 | inputs = inputs.permute(3, 0, 1, 2) |
| 317 | # Sample frames for num_frames specified. |
| 318 | index = torch.linspace(0, inputs.shape[1] - 1, cfg.DATA.NUM_FRAMES).long() |
| 319 | inputs = torch.index_select(inputs, 1, index) |
| 320 | inputs = pack_pathway_output(cfg, inputs) |
| 321 | inputs = [inp.unsqueeze(0) for inp in inputs] |
| 322 | return inputs |
| 323 | |
| 324 | |
| 325 | def get_layer(model, layer_name): |
no test coverage detected