IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Python class

ImageMetadata

ImageMetadata

class max.pipelines.context.ImageMetadata(*, start_idx, end_idx, pixel_values, image_hash=None, num_embedding_rows=None)

source

Bases: object

Metadata about an image in the prompt.

Each image corresponds to a range in the text token array [start_idx, end_idx).

Parameters:

embedding_rows

property embedding_rows: int

source

Embedding rows for this entry (span width unless overridden).

end_idx

end_idx: int

source

One after the index of the last <vision_token_id> special token for the image

image_hash

image_hash: int | None = None

source

Hash of the image, for use in prefix caching

num_embedding_rows

num_embedding_rows: int | None = None

source

Embedding rows the encoder emits for this entry.

None means every token in [start_idx, end_idx) is a placeholder, so the row count equals the span width. Set by tokenizers whose spans interleave placeholder runs with other tokens (e.g. video timestamp text).

pixel_values

pixel_values: ndarray[tuple[Any, ...], dtype[Any]]

source

Pixel values for the image.

Can be various dtypes depending on the vision model:

  • float32: Original precision
  • uint16: BFloat16 bits stored as uint16 (workaround for NumPy’s lack of native bfloat16 support). Reinterpreted as bfloat16 on GPU.

start_idx

start_idx: int

source

Index of the first <vision_token_id> special token for the image