MCPcopy Create free account
hub / github.com/ChenHsing/SVFormer / process_cv2_inputs

Function process_cv2_inputs

timesformer/visualization/utils.py:303–321  ·  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

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

Callers

nothing calls this directly

Calls 2

tensor_normalizeFunction · 0.90
pack_pathway_outputFunction · 0.90

Tested by

no test coverage detected