Vision
Provides machine learning and computer vision capabilities for document processing. Enables AI-powered document description and content extraction.
from nutrient import VisionClass Methods
set
@classmethoddef set(cls, document: Document) -> VisionCreates a Vision instance for the specified document.
Parameters:
| Name | Type | Description |
|---|---|---|
document | Document | The 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) -> strGenerates an AI-powered description of the document content.
Returns: str - A string containing the document description.
extract_content
def extract_content(self) -> strExtracts 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) -> strExtracts structured content from the document using machine vision processing with custom export settings. The pipeline used is determined by the setting.
Parameters:
| Name | Type | Description |
|---|---|---|
settings | DocumentLayoutJsonExportSettings | Settings 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) -> NoneExtracts structured content from the document and saves it to a JSON file. Uses the document’s DocumentLayoutJsonExportSettings for configuration.
Parameters:
| Name | Type | Description |
|---|---|---|
output_path | str | Path to the output JSON file. |
extract_content_to_file
def extract_content_to_file(self, output_path: str, settings: DocumentLayoutJsonExportSettings) -> NoneExtracts structured content from the document and saves it to a JSON file with custom settings.
Parameters:
| Name | Type | Description |
|---|---|---|
output_path | str | Path to the output JSON file. |
settings | DocumentLayoutJsonExportSettings | Settings controlling what to include in the JSON output. |
warmup
def warmup(self) -> NonePreloads (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().