pyflink.multimodal.utils.normalize_batch#
- normalize_batch(batch, mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225))[source]#
Normalize a batch of images.
Converts uint8 [0, 255] images to float32 and normalizes with the given mean and std. Defaults to ImageNet statistics.
- Parameters
batch – np.ndarray with shape
(N, H, W, C), dtype uint8.mean – Per-channel means (scaled to [0, 1]). Length must match the number of channels in batch.
std – Per-channel standard deviations (scaled to [0, 1]). Length must match the number of channels in batch.
- Returns
np.ndarray with shape
(N, H, W, C), dtype float32.
Example:
batch = resize_batch(pixel_arrays, (224, 224)) normed = normalize_batch(batch) # ImageNet normalization