Image input

Which photo regions decided a vision model’s answer? Each region is a player; greying it out and re-scoring measures its weight. Two examples come first.

A coin shop front; the cell over the small red OPEN sign in the door is shaded red.

“Is the shop open?” Qwen2.5-VL-3B says yes, crediting the small OPEN sign in the door over the neon lettering.

A crowded street with umbrellas; the cells over the umbrellas are shaded red.

“Is it raining?” No raindrops are visible; the answer comes from the umbrellas.

A cat lying on a couch; the cells over its face are shaded blue.

“Is there a dog in this picture?” The model says no; the cat’s face is the evidence (blue).

Values: log-odds of “Yes” against “No” (label_margin), 6 by 6 grid. Notebook: Which part of the photo decided the answer?; other views: Visualization.

Backends

A message can carry ImagePart content (path or encoded bytes) next to its text. Images need the image extra (Pillow).

kind

Extra

Image parts

transformers

[transformers]

Sent through the processor’s chat template (Qwen2.5-VL, Qwen3-Omni)

api

[api,image]

Sent as image_url data URIs (PNG and JPEG as they are)

lmstudio

[lmstudio,image]

Uploaded once each and attached to their user message

mock_image

[image]

One token per visible coloured square, for tests and demos

Image players

image_grid cuts each image into rows by cols cells with edges on snap_px steps (patch size times merge: 28 for Qwen2.5-VL, 32 for Qwen3-Omni), so cell sizes may differ. image_boxes makes each box category of the first image a player, plus the background; overlaps go to the smaller category. question: true adds the message’s words as players.

explanation:
  players: image_boxes
  absence_policy: pad
  plugin_options:
    image_boxes:
      boxes: {dog: [[12.5, 40.0, 210.0, 180.5]], ball: [[150, 160, 190, 200]]}
    pad:
      image_fill: blur

Boxes are [left, top, right, bottom] pixels, rounded outward (convert COCO’s [x, y, width, height]).

The coin shop photo with two boxes; the neon sign reading "Scrap gold and silver" is shaded red; the OPEN sign box is barely shaded.

image_boxes with open_sign and neon_sign boxes. For “Does this shop buy gold?” Qwen2.5-VL-3B credits the neon sign (+2.73) over the OPEN sign (-0.46); “Is the shop open?” credits the OPEN sign.

Fills

pad, neutral and infill take image_fill: grey (default), mean colour, Gaussian blur or noise seeded by the image bytes. A mask always renders the same PNG; a fill other than grey enters the coalition key. delete refuses region players; it drops an image only when all its whole-image players are absent.

Removal metrics

Cells and boxes differ in area, so image_removal_metrics() counts snap_px patches: random controls remove as many patches as the top-k players own. Use another fill than the explanation’s, or the metrics are flagged circular.

Models in transformers

TransformersTextBackend loads a vision model with its processor as for audio (Audio input); a text model refuses images with ValueError. generation.content_order puts media first (legacy) or in place (in_order). backend.options.processor_kwargs (max_pixels) goes to the processor. Teacher forcing uses the image features. Omni models run through their text thinker, without the prefix cache.

plot_image_players() shades each player’s boxes over its picture; plot_conversation() adds one strip per image below the text.