MCPcopy Create free account
hub / github.com/OpenGVLab/UniFormerV2 / process_cv2_inputs

Function process_cv2_inputs

slowfast/visualization/utils.py:304–322  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

302
303
304def 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
325def get_layer(model, layer_name):

Callers 2

__call__Method · 0.90
get_input_clipMethod · 0.90

Calls 2

tensor_normalizeFunction · 0.90
pack_pathway_outputFunction · 0.90

Tested by

no test coverage detected