Skip to main content
The MultiModalProcessor class handles preprocessing of images, audio, and text for vision-language and audio-language models.

Constructor

Create a multimodal processor from a model.
The processor is created using the create_multimodal_processor() method on a Model object.

Methods

call()

Process text prompts along with images and/or audio into model inputs.
str | list[str] | None
default:"None"
Text prompt(s) to process. Can be:
  • A single string
  • A list of strings for batch processing
  • None if only processing media without text
Images
default:"None"
Images object containing one or more images
Audios
default:"None"
Audios object containing one or more audio files
NamedTensors
Preprocessed inputs ready to pass to Generator.set_inputs()

decode()

Decode token IDs back to text.
numpy.ndarray
required
Array of int32 token IDs to decode
str
The decoded text string

create_stream()

Create a streaming tokenizer for incremental decoding.
TokenizerStream
A TokenizerStream object for streaming decoding

Images Class

Load and manage images for multimodal processing.

open()

Load images from file paths.
str
required
One or more file paths to image files
Images
Images object containing the loaded images

open_bytes()

Load images from bytes in memory.
bytes
required
One or more byte objects containing image data
Images
Images object containing the loaded images

Audios Class

Load and manage audio files for multimodal processing.

open()

Load audio files from file paths.
str
required
One or more file paths to audio files
Audios
Audios object containing the loaded audio files

open_bytes()

Load audio from bytes in memory.
bytes
required
One or more byte objects containing audio data
Audios
Audios object containing the loaded audio files

Example Usage

Vision-language model (Phi-3 Vision):
Multiple images:
Audio transcription:
Multimodal with images and audio (Phi-4):
Batch processing multiple prompts:
Loading from bytes: