Browse our Products

Latest Release

What was changed

KeySummaryCategory
OCRNET‑1199Performance and Memory Consumption issue: add set_enable_memory_pattern and set_enable_cpu_mem_arena to configure ONNX Runtime.Enhancement

Public API changes and backwards compatibility

This section lists all public API changes introduced in Aspose.OCR for Python via .NET 26.3 that may affect the code of existing applications.

Added public APIs:

No changes.

Updated public APIs:

The following public APIs have been updated in this release:

Aspose.OCR.OnnxRuntimeSessionOptions

Added property ‘set_enable_memory_pattern’

Added property ‘set_enable_cpu_mem_arena’

Removed public APIs:

No changes.

Examples

The code samples below illustrate the changes introduced in this release:

OnnxRuntimeSessionOptions

from aspose.ocr.models import *


# Initialize recognition API
api = new AsposeOcr()

# ONNX runtime settings
OnnxRuntimeSessionOptions.set_intra_op_num_threads(1)
OnnxRuntimeSessionOptions.set_graph_optimization_level(GraphOptimizationLevelOnnx.ORT_ENABLE_EXTENDED)
OnnxRuntimeSessionOptions.set_execution_mode(ExecutionModeOnnx.ORT_SEQUENTIAL)
OnnxRuntimeSessionOptions.set_inter_op_num_threads(1)

# When enabled saves memory usage but increases execution time
OnnxRuntimeSessionOptions.set_enable_memory_pattern(True)
OnnxRuntimeSessionOptions.set_enable_cpu_mem_arena(True)

# Add an image to OcrInput object
input = new OcrInput(InputType.SINGLE_IMAGE)
input.add("source.png")

# Recognize image
results = api.recognize(input)