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.resize_batch#

resize_batch(images, target_size, strategy='resize', interpolation=None)[source]#

Resize a batch of differently-sized ndarrays to a uniform size.

Intended for pandas batch UDFs to unify images from safe_decode_batch() into a stackable batch.

Parameters
  • images – List of ndarrays (RGB images), each potentially a different size.

  • target_size – (height, width) target dimensions.

  • strategy –

    Resize strategy:

    • "resize": Scale directly to target (may change aspect ratio).

    • "pad": Scale keeping aspect ratio, pad shorter side with black.

    • "crop": Scale keeping aspect ratio, center-crop to target.

  • interpolation – Interpolation method. Defaults to cv2.INTER_LINEAR (if cv2 is available) or PIL LANCZOS. Pass None to auto-select.

Returns

np.ndarray with shape (N, H, W, C).

Example:

pixel_arrays, idx = safe_decode_batch(series, mode="RGB")
batch = resize_batch(pixel_arrays, (224, 224))
# batch.shape == (len(pixel_arrays), 224, 224, 3)

previous

pyflink.multimodal.utils.run_image_batch_inference

next

pyflink.multimodal.utils.normalize_batch

Show Source

Created using Sphinx 4.5.0.