Function Signature
Description
The main function for extracting and processing all vision information (images and videos) from conversation messages. It automatically detects vision content, loads the media, applies smart resizing, and returns processed inputs ready for model processors.Parameters
Union[List[Dict[str, Any]], List[List[Dict[str, Any]]]]
required
Conversation messages containing vision content. Can be:
- A single conversation:
[{"role": "user", "content": [...]}] - Multiple conversations:
[[{"role": "user", "content": [...]}], ...]
type and corresponding media keys:- Images:
{"type": "image", "image": "path/url/base64"} - Videos:
{"type": "video", "video": "path/url"}
bool
default:"False"
Whether to return video-specific keyword arguments (like fps) for the processor.Required for Qwen2.5VL models that need video processing parameters.
bool
default:"False"
Whether to return video metadata (fps, frame indices, total frames, backend) alongside video tensors.Required for Qwen3VL models that need detailed video metadata.
int
default:"14"
The patch size used by the vision encoder. Affects resizing calculations.Common values:
14for Qwen2VL and Qwen2.5VL16for Qwen3VL
Returns
Optional[List[PIL.Image.Image]]
List of processed PIL Image objects, or
None if no images found.Images are resized using smart_resize to optimal dimensions based on min_pixels and max_pixels.Optional[List[Union[torch.Tensor, Tuple[torch.Tensor, Dict]]]]
List of processed video tensors with shape
(T, C, H, W), or None if no videos found.If return_video_metadata=True, each item is a tuple of (video_tensor, metadata_dict).Optional[Dict[str, Any]]
Dictionary of video processing parameters (only returned if
return_video_kwargs=True).Contains:do_sample_frames: AlwaysFalsefps: List of sample fps values (only ifreturn_video_metadata=False)
Usage Examples
Qwen2VL
Qwen2.5VL
Qwen3VL
Vision Content Formats
Image Content
Video Content
See Also
- fetch_image - Load individual images
- fetch_video - Load individual videos
- smart_resize - Resize images intelligently