> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/automodel/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/automodel/_mcp/server.

# nemo_automodel.components.models.glm5_next.image_processing

Image-only backport of the GLM-5.3 dynamic patch processor.

## Module Contents

### Classes

| Name                                                                                                                        | Description                                                      |
| --------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| [`Glm5NextImageProcessor`](#nemo_automodel-components-models-glm5_next-image_processing-Glm5NextImageProcessor)             | Dynamically resize, normalize and flatten GLM-5.3 image patches. |
| [`Glm5NextImageProcessorKwargs`](#nemo_automodel-components-models-glm5_next-image_processing-Glm5NextImageProcessorKwargs) | Additional dynamic resize and patchification options.            |

### Functions

| Name                                                                                        | Description                                                      |
| ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| [`smart_resize`](#nemo_automodel-components-models-glm5_next-image_processing-smart_resize) | Return an aligned H/W canvas inside the configured token budget. |

### Data

[`__all__`](#nemo_automodel-components-models-glm5_next-image_processing-__all__)

### API

```python
class nemo_automodel.components.models.glm5_next.image_processing.Glm5NextImageProcessor()
```

**Bases:** `TorchvisionBackend`

Dynamically resize, normalize and flatten GLM-5.3 image patches.

**`max_image_tokens`** `= 8000`

---

**`merge_size`** `= 2`

---

**`min_image_tokens`** `= 16`

---

**`model_input_names`** `= ['pixel_values', 'image_grid_thw']`

---

**`patch_expand_factor`** `= 1`

---

**`patch_size`** `= 14`

---

**`resample`** `= PILImageResampling.BICUBIC`

---

**`rescale_factor`** `= 1 / 255`

---

**`size`** `= {'longest_edge': 1}`

---

**`temporal_patch_size`** `= 2`

---

```python
nemo_automodel.components.models.glm5_next.image_processing.Glm5NextImageProcessor._preprocess(
    images: list[torch.Tensor],
    do_resize: bool,
    size: transformers.image_utils.SizeDict,
    resample,
    do_rescale: bool,
    rescale_factor: float,
    do_normalize: bool,
    image_mean,
    image_std,
    patch_size: int,
    temporal_patch_size: int,
    merge_size: int,
    patch_expand_factor: int,
    min_image_tokens: int,
    max_image_tokens: int,
    disable_grouping: bool | None,
    return_tensors,
    kwargs = {}
) -> transformers.image_processing_utils.BatchFeature
```

Implement TorchvisionBackend's grouped preprocessing contract.

```python
nemo_automodel.components.models.glm5_next.image_processing.Glm5NextImageProcessor.get_number_of_image_patches(
    height: int,
    width: int,
    images_kwargs: dict | None = None
) -> int
```

Return the number of unmerged vision patches for one source image.

```python
nemo_automodel.components.models.glm5_next.image_processing.Glm5NextImageProcessor.patchify(
    images: torch.Tensor,
    patch_size: int,
    merge_size: int,
    temporal_patch_size: int
) -> tuple[torch.Tensor, int, int]
```

staticmethod

Flatten block-major duplicated temporal patches.

```python
nemo_automodel.components.models.glm5_next.image_processing.Glm5NextImageProcessor.resize(
    images: torch.Tensor,
    resample,
    factor: int,
    temporal_factor: int,
    min_image_tokens: int,
    max_image_tokens: int,
    kwargs = {}
) -> torch.Tensor
```

Aspect-preserving resize followed by right/bottom zero padding.

```python
class nemo_automodel.components.models.glm5_next.image_processing.Glm5NextImageProcessorKwargs()
```

**Bases:** `ImagesKwargs`

Additional dynamic resize and patchification options.

**`max_image_tokens`** `int`

---

**`merge_size`** `int`

---

**`min_image_tokens`** `int`

---

**`patch_expand_factor`** `int`

---

**`patch_size`** `int`

---

**`temporal_patch_size`** `int`

---

```python
nemo_automodel.components.models.glm5_next.image_processing.smart_resize(
    num_frames: int,
    height: int,
    width: int,
    temporal_factor: int = 2,
    factor: int = 28,
    min_pixels: int = 16,
    max_pixels: int = 8000
) -> tuple[int, int]
```

Return an aligned H/W canvas inside the configured token budget.

```python
nemo_automodel.components.models.glm5_next.image_processing.__all__ = ['Glm5NextImageProcessor', 'smart_resize']
```