Ctrl+K
Logo image Logo image

Site Navigation

  • API Reference
  • Examples

Site Navigation

  • API Reference
  • Examples

Section Navigation

  • PyFlink Table
  • PyFlink DataFrame
  • PyFlink Multimodal
    • Image
    • Video
    • Utilities
  • PyFlink DataStream
  • PyFlink Common

pyflink.multimodal.utils.batch_to_tensor#

batch_to_tensor(batch, device=None)[source]#

Convert an ndarray batch to a PyTorch tensor.

Performs HWC -> CHW transposition (PyTorch convention) and optional device transfer. If the input is uint8, it is converted to float32 and scaled to [0, 1] first; float32 input is used as-is.

Parameters
  • batch – np.ndarray with shape (N, H, W, C).

  • device – Target device (str or torch.device), e.g. "cuda:0". None means CPU.

Returns

torch.Tensor with shape (N, C, H, W), dtype float32.

Example:

batch = resize_batch(pixel_arrays, (224, 224))
normed = normalize_batch(batch)
tensor = batch_to_tensor(normed, device="cuda:0")
output = model(tensor)

previous

pyflink.multimodal.utils.normalize_batch

next

PyFlink DataStream

Show Source

Created using Sphinx 4.5.0.