Provides machine learning and computer vision capabilities for document processing. Enables AI-powered document description and content extraction.

from nutrient import Vision

Class Methods

set

@classmethod
def set(cls, document: Document) -> Vision

Creates a Vision instance for the specified document.

Parameters:

NameTypeDescription
documentDocumentThe document to analyze using vision capabilities.

Returns: Vision - A Vision instance ready to perform analysis on the document. Raises:

  • NullOrEmptyParameterException: Thrown when document is null.

Methods

describe

def describe(self) -> str

Generates an AI-powered description of the document content.

Returns: str - A string containing the document description.


extract_content

def extract_content(self) -> str

Extracts structured content from the document using machine vision processing. The pipeline used is determined by the setting.

Returns: str - A JSON string containing the extracted content structure with zones, lines, words, and bounds.


extract_content

def extract_content(self, settings: DocumentLayoutJsonExportSettings) -> str

Extracts structured content from the document using machine vision processing with custom export settings. The pipeline used is determined by the setting.

Parameters:

NameTypeDescription
settingsDocumentLayoutJsonExportSettingsSettings controlling what to include in the JSON output.

Returns: str - A JSON string containing the extracted content structure.


extract_content_to_file

def extract_content_to_file(self, output_path: str) -> None

Extracts structured content from the document and saves it to a JSON file. Uses the document’s DocumentLayoutJsonExportSettings for configuration.

Parameters:

NameTypeDescription
output_pathstrPath to the output JSON file.

extract_content_to_file

def extract_content_to_file(self, output_path: str, settings: DocumentLayoutJsonExportSettings) -> None

Extracts structured content from the document and saves it to a JSON file with custom settings.

Parameters:

NameTypeDescription
output_pathstrPath to the output JSON file.
settingsDocumentLayoutJsonExportSettingsSettings controlling what to include in the JSON output.

warmup

def warmup(self) -> None

Preloads (warms up) all resources needed for vision processing. This downloads all model files based on the document’s VisionSettings before execution. Call this to avoid download delays during ExtractContent().