DiffusionGemmaImageConverter classkeras_hub.layers.DiffusionGemmaImageConverter(
patch_size=16, max_soft_tokens=280, pooling_kernel_size=3, **kwargs
)
Preprocess raw images for Gemma4 vision inputs.
Resizes images using aspect-ratio-preserving scaling to the nearest
valid resolution (a multiple of patch_size * pooling_kernel_size),
then applies optional per-channel rescaling and offset. The output is a
dict with keys "pixel_values" (the flattened patch tensor) and
"pixel_position_ids" (2-D (x, y) position indices for each patch).
Arguments
16.280.patch_size to compute
valid target dimensions. Defaults to 3.keras_hub.layers.ImageConverter, e.g. scale, offset.from_preset methodDiffusionGemmaImageConverter.from_preset(preset, **kwargs)
Instantiate a keras_hub.layers.ImageConverter from a model preset.
A preset is a directory of configs, weights and other file assets used
to save and load a pre-trained model. The preset can be passed as
one of:
'pali_gemma_3b_224''kaggle://user/paligemma/keras/pali_gemma_3b_224''hf://user/pali_gemma_3b_224''./pali_gemma_3b_224'You can run cls.presets.keys() to list all built-in presets available
on the class.
Arguments
True, the weights will be loaded into the
model architecture. If False, the weights will be randomly
initialized.Examples
batch = np.random.randint(0, 256, size=(2, 512, 512, 3))
# Resize images for `"pali_gemma_3b_224"`.
converter = keras_hub.layers.ImageConverter.from_preset(
"pali_gemma_3b_224"
)
converter(batch) # # Output shape (2, 224, 224, 3)
# Resize images for `"pali_gemma_3b_448"` without cropping.
converter = keras_hub.layers.ImageConverter.from_preset(
"pali_gemma_3b_448",
crop_to_aspect_ratio=False,
)
converter(batch) # # Output shape (2, 448, 448, 3)
| Preset | Parameters | Description |
|---|---|---|
| diffusion_gemma_26b_a4b_it | 25.82B | DiffusionGemma 26B MoE instruction-tuned model. 25.8B total parameters (3.8B active), 30 layers, 128 experts. |