---
title: "Speeding up first ICR operation by predownloading models | Nutrient Python SDK"
canonical_url: "https://www.nutrient.io/guides/python/extraction/speed-up-first-icr-by-downloading-requirements/"
md_url: "https://www.nutrient.io/guides/python/extraction/speed-up-first-icr-by-downloading-requirements.md"
last_updated: "2026-05-30T02:20:01.349Z"
description: "Predownload Vision API models to eliminate first-request latency using Nutrient Python SDK."
---

# Speeding up first ICR operation by predownloading models

Use warmup to pre-download vision models before processing documents.

Common use cases include:

- Removing first-request latency in user-facing apps

- Preparing batch jobs before processing starts

- Marking containers ready only after dependencies are available

- Preloading models before offline operation

- Meeting latency targets for production APIs

This guide shows how to warm up ICR models so `extract_content()` runs without initial download delays.

[Download sample](https://www.nutrient.io/downloads/samples/python/speed-up-first-icr-by-downloading-requirements.zip)

## How Nutrient helps

Nutrient Python SDK handles model download orchestration and cache management.

The SDK handles:

- Model downloads and cache storage details

- Engine-specific model dependencies

- Download retries and transient failure handling

- Readiness checks for model availability

## Complete implementation

This example warms up ICR models and then runs extraction:

```python

from nutrient_sdk import Document, Vision
from nutrient_sdk.settings import VisionEngine

```

## Warming up Vision API

Open a document in a [context manager](https://docs.python.org/3/reference/datamodel.html#context-managers), set `VisionEngine.Icr`, create a vision instance, and call `warmup()`.

In this sample:

- `vision_settings.engine = VisionEngine.ICR` selects ICR mode.

- `vision.warmup()` downloads required models.

- Models are cached for subsequent requests.

- Print statements show progress.

```python

with Document.open("input.png") as document:
    # Configure ICR engine

    document.settings.vision_settings.engine = VisionEngine.ICR

    # Create Vision instance

    vision = Vision.set(document)

    # Pre-download all required models

    # This ensures subsequent extract_content() calls are fast

    print("Downloading Vision models...")
    vision.warmup()
    print("Models ready!")

```

## Processing documents after warmup

After warmup, run `extract_content()` without download latency.

In this sample:

- `extract_content()` returns a JSON string.

- The JSON output is written to `output.json`.

- File handling uses a nested context manager.

```python

    # Now extract_content() won't need to download anything

    content_json = vision.extract_content()

    with open("output.json", "w") as f:
        f.write(content_json)

```

## Best practices

Apply these patterns for using warmup effectively in production environments:

- **Application startup** — Run warmup before accepting requests.

- **Background thread** — Run warmup asynchronously during initialization.

- **Health checks** — Expose warmup status in readiness probes.

- **Deployment pipelines** — Validate model availability during deployment.

- **Offline environments** — Download models while connected, then process offline.

## What gets downloaded?

Warmup downloads model sets based on `VisionSettings.engine`:

- **ICR mode** (`VisionEngine.ICR`) — Layout, text, tables, equations, and key-value detection models

- **OCR mode** (`VisionEngine.ADAPTIVE_OCR`) — OCR language and text recognition resources

- **VLM-enhanced mode** (`VisionEngine.VLM_ENHANCED_ICR`) — ICR resources plus VLM-related resources

Downloaded models are cached locally and reused across restarts until the cache is cleared or models are updated.

## Conclusion

Use this workflow to pre-download ICR requirements:

1. Open a document using a [context manager](https://docs.python.org/3/reference/datamodel.html#context-managers) for automatic resource cleanup after warmup and processing complete.

2. The SDK supports multiple document formats, including PNG, JPEG, PDF, and TIFF for vision operations.

3. Access the vision settings with `document.settings.vision_settings.engine` to configure the vision engine.

4. Set the engine to ICR with property assignment `VisionEngine.ICR` to enable advanced document understanding with layout detection, text recognition, table extraction, equation recognition, and key-value pair detection.

5. Alternative engines include OCR mode for basic text extraction and VLM-enhanced mode for semantic understanding with vision language models.

6. Create a vision instance with `Vision.set()` bound to the document with configured engine settings.

7. Call `vision.warmup()` to trigger pre-download of all AI models required for the configured vision engine, fetching models from the SDK’s model repository and caching them locally.

8. Warmup downloads different model sets based on engine configuration — ICR downloads comprehensive document understanding models, OCR downloads text recognition models, and VLM downloads ICR models plus semantic understanding resources.

9. Print statements provide feedback during model downloads, informing users about download progress and completion status for potentially multi-second operations.

10. After warmup completes, call `vision.extract_content()` to perform ICR operations without model download delays, ensuring predictable and fast processing for all subsequent requests.

11. The `extract_content()` method returns extracted content as JSON, including document structure (headings, paragraphs, tables, lists), textual content, table structures, equations, and key-value pairs.

12. Write the extracted JSON to a file using a nested context manager with `open()` for automatic resource cleanup after writing completes.

13. Handle `NutrientException` for vision processing failures, including model download errors, processing failures, or configuration issues.

14. The context manager ensures proper resource cleanup when processing completes or exceptions occur.

For related image extraction workflows, refer to the [Python SDK guides](https://www.nutrient.io/guides/python.md).

Download [this ready-to-use sample package](https://www.nutrient.io/downloads/samples/python/speed-up-first-icr-by-downloading-requirements.zip) to integrate warmup into application startup.
---

## Related pages

- [Generating image descriptions using local AI](/guides/python/extraction/describe-image-with-local-ai.md)
- [Generating image descriptions using Claude](/guides/python/extraction/describe-image-with-claude.md)
- [Extracting data from images using ICR](/guides/python/extraction/extract-data-from-image-icr.md)
- [Applying OCR to a PDF page](/guides/python/extraction/apply-ocr-to-pdf-page.md)
- [Extracting text from multilingual images](/guides/python/extraction/read-text-from-image-multi-language.md)
- [Nutrient Python SDK extraction guides](/guides/python/extraction.md)
- [Extracting structured JSON data from PDF documents](/guides/python/extraction/json-data-extraction.md)
- [Extracting data from images using vision language models](/guides/python/extraction/extract-data-from-image-vlm.md)
- [Extracting text from images](/guides/python/extraction/read-text-from-image.md)
- [Extracting data from images using OCR](/guides/python/extraction/extract-data-from-image-ocr.md)
- [Applying OCR to a PDF document](/guides/python/extraction/apply-ocr-to-pdf.md)
- [Generating image descriptions using OpenAI](/guides/python/extraction/describe-image-with-openai.md)

