Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:InternLM Lmdeploy Load Image

From Leeroopedia


Knowledge Sources
Domains Vision_Language_Models, Image_Processing
Last Updated 2026-02-07 15:00 GMT

Overview

Concrete tool for loading images from multiple sources into PIL Image format for VLM inference provided by the LMDeploy library.

Description

The load_image() function accepts HTTP URLs, local file paths, base64 data URIs, or PIL Image objects and returns a PIL Image in RGB mode. It handles downloading, decoding, and format conversion automatically.

Usage

Import this when preparing image inputs for VLM pipeline inference. Pass the resulting PIL Image in a tuple with the text prompt to Pipeline.__call__().

Code Reference

Source Location

  • Repository: lmdeploy
  • File: lmdeploy/vl/utils.py
  • Lines: L52-83

Signature

def load_image(image_url: Union[str, Image.Image]) -> Image.Image:
    """Load image from URL, file path, base64, or PIL Image."""
    ...

Import

from lmdeploy.vl import load_image

I/O Contract

Inputs

Name Type Required Description
image_url str or PIL.Image.Image Yes HTTP URL, local path, base64 data URI, or PIL Image

Outputs

Name Type Description
image PIL.Image.Image RGB-mode PIL Image ready for VLM processing

Usage Examples

from lmdeploy.vl import load_image
from lmdeploy import pipeline, TurbomindEngineConfig

# Load images from various sources
img1 = load_image('https://example.com/photo.jpg')
img2 = load_image('/path/to/local/image.png')

# Create pipeline for VLM
pipe = pipeline('OpenGVLab/InternVL2-8B',
                backend_config=TurbomindEngineConfig(session_len=8192))

# Pass image-text pairs as tuples
response = pipe(('Describe this image', img1))
print(response.text)

# Batch with multiple images
responses = pipe([
    ('What is in this image?', img1),
    ('Describe this photo', img2)
])

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment