This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/python/extraction/describe-image-with-local-ai.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Generating image descriptions using local AI | Nutrient Python SDK

Use local AI image description when you need privacy, cost control, or offline operation.

Common use cases include:

  • On-premises accessibility workflows
  • Medical or regulated environments with local-only data handling
  • Secure networks where external APIs are restricted
  • High-volume processing without per-image API fees
  • Offline-capable applications

Nutrient Python SDK 1.0.12 and later include a Local provider for zero-configuration local AI. The Local provider runs a model in the SDK process, downloads required model files automatically on first use, and uses GPU acceleration when available.

Download sample

How Nutrient helps

Nutrient Python SDK handles in-process local model loading, image preparation, and response parsing.

The SDK handles:

  • Zero-configuration Local provider setup
  • Automatic model downloads into the persistent SDK resource cache
  • GPU acceleration when supported by the current system
  • Image encoding and multimodal payload construction
  • Model loading and processing errors

Complete implementation

This example generates image descriptions using the default in-process Local provider:

from nutrient_sdk import Document, Vision, NutrientException

Opening the image file

Open the image in a context manager(opens in a new tab). The Local provider is the default in version 1.0.12 and later, so no endpoint or model-server configuration is required.

In this sample:

  • The SDK supports PNG, JPEG, GIF, BMP, and TIFF.
  • Required model files download automatically on first use.
  • GPU acceleration is used when available.
try:
with Document.open("input_photo.png") as document:

Creating a vision instance

Create a vision instance with Vision.set(document).

Before calling vision methods, ensure the application can write to the SDK resource cache so model files can be stored after the first download.

vision = Vision.set(document)

Generating the description

Call vision.describe() to generate a natural language description.

The SDK handles image encoding, request construction, and response parsing:

description = vision.describe()

Outputting the description

Print the description for review, or store it in your application.

Common destinations include:

  • Database fields
  • JSON output files
  • HTML alt attributes
print("Image description:")
print(description)
except NutrientException as e:
print(f"Error: {e}")
raise

Understanding the output

describe() returns natural language text generated by the local model.

Descriptions are typically:

  • Concise — Focused on key subjects and details, often one to three sentences
  • Accessible — Suitable for users who rely on screen readers
  • Accurate — Based on visible content only
  • Model-dependent quality — Quality varies by model architecture and size

Use this output for accessibility metadata, image search, and document workflows, all with local processing.

Error handling

The SDK raises NutrientException when vision operations fail.

Common failure scenarios include:

  • The input image can’t be read due to path, permission, or format issues
  • Required local model files can’t be downloaded or read from the SDK resource cache
  • Available CPU/GPU memory is insufficient for the local model
  • Responses time out on large images or heavy models

In production code:

  • Catch NutrientException.
  • Return a clear error message.
  • Log failure details for debugging.
  • Add retry logic for transient model download or processing issues.

Conclusion

Use this workflow to generate image descriptions with local AI:

  1. Open the image file using a context manager(opens in a new tab) for automatic resource cleanup.
  2. The SDK supports multiple image formats, including PNG, JPEG, GIF, BMP, and TIFF.
  3. The SDK uses the in-process Local provider by default, downloads required model files automatically, and uses GPU acceleration when available.
  4. Create a vision instance with Vision.set() bound to the document.
  5. Generate the description with vision.describe(), which processes the image with the Local provider and returns natural language text.
  6. Print or save the description for use in accessibility systems, content management, or cataloging workflows.
  7. Handle NutrientException for vision processing failures, including model download, resource-cache, memory, or timeout errors.

To use an external OpenAI-compatible local VLM endpoint, refer to the custom local AI endpoint guide. For related image workflows, refer to the Python SDK guides.

Download this ready-to-use sample package to explore local AI image description.