Setup
Install PyTorch, Transformers, and the image packages used by the examples.torchvision and Pillow are required by the image processor, and opencv-python draws the layout boxes.
The examples use the recommended sampling parameters for the model shown. For another model, use the values from its model page.
- LFM3
- LFM2/LFM2.5
AutoProcessor and AutoModelForImageTextToText:enable_thinking=False below for direct answers. The examples pass this setting to the processor. Transformers then parses the response using the checkpoint’s response_template, including the assistant prefix already inserted by the chat template. See Thinking for reasoning controls.Single-image prompt
Provide one image and a text question in the same user message. This pattern is useful for captioning, visual question answering, and scene understanding.
- LFM3
- LFM2/LFM2.5
Multi-image prompt
You can include multiple images in a single prompt. Label each image in the prompt, such asMedia-1 and Media-2, to make cross-image references clearer.

- LFM3
- LFM2/LFM2.5
OCR
LFM vision models read text in document images and screenshots. OCR works best when text is legible and the image is not blurry, rotated, or heavily compressed. For dense documents, crop to the relevant page or region when possible.
- LFM3
- LFM2/LFM2.5
Document layout annotations
- LFM3
- LFM2/LFM2.5
Pointing
- LFM3
- LFM2/LFM2.5
This example uses LFM3-VL-2B, loaded in Setup.Pointing asks the model to locate visible objects with a single point each. The model returns Output
{"point_2d": [x, y]}, with x and y as integers normalized to [0, 1000]. This example asks for a point on each cat and each remote control, then draws the points.
Object detection and grounding
Grounding asks the model to localize visible objects with bounding boxes. This example uses the cat photo from Single-image prompt, asks for boxes in[xmin, ymin, xmax, ymax] format normalized to [0, 1000], then draws the returned boxes.
Convert normalized coordinates back to pixels with x / 1000 * width and y / 1000 * height. Boxes are approximate, so visually inspect the result before using coordinates in downstream workflows.
- LFM3
- LFM2/LFM2.5
- LFM3
- LFM2/LFM2.5

Ask about an image by voice
Spoken questions about an image require an omni model with image and audio input. Load it as shown in Audio Capabilities.
Describe the provided image. for captions, and Answer questions about the provided image. Base every answer only on what can be seen. for questions. When the answer should be in a different modality from the question, add an output instruction after the task prompt, for example Respond with text.
This example first records a spoken question with text-to-speech, then asks it about a photo:
Video understanding
Video-capable models can answer questions using a clip’s frames. Check the model page for the default frame rate and frame limits. Installtorchcodec and FFmpeg for video decoding in addition to the packages in Setup:
Describe a video
Pass a local path with{"type": "video", "video": ...}. This example downloads a short sample clip:
- LFM3
- LFM2/LFM2.5
Use the soundtrack
Soundtrack input requires an omni model with video and audio input. Load it as shown in Audio Capabilities.
load_audio_from_video=True and processor_kwargs={"use_audio_in_video": True} so the processor interleaves the soundtrack with the frames:
FAQ
Which vision model should I use? Choose a vision model based on the task: a smaller model for fast captioning and visual questions, a model with layout support for documents, or a thinking model for harder questions and spatial tasks. Choose an omni model when the request also involves speech or a video’s soundtrack. See the model library for current options. Can I turn off reasoning? On models that support switching thinking off, passenable_thinking=False to apply_chat_template() for direct answers with lower latency. See Thinking for support and controls.
What image formats are supported?
LFM vision models work with common image formats such as JPEG and PNG. In the examples above, images are loaded from Hugging Face URLs with transformers.image_utils.load_image.
What video formats are supported?
The video examples accept files that torchcodec can decode, such as MP4.
How precise are points and boxes?
Boxes and points are approximate and can vary with prompt wording, image resolution, and generation settings. For workflows that require precise localization, inspect the returned coordinates and validate them against the original image.
Can the models generate or edit images?
No. LFM vision models are image and video understanding models. They can analyze images, answer questions, read text, localize objects, parse layouts, and route tool calls, but they do not generate or edit images.
