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. PassNoneto 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)