Skip to content

EasyOcrSharp 3.1.1: GPU runtime fix, PaddleOcrNet 2.1.0 structure engine, OCR accuracy fixes

Choose a tag to compare

@FarhanLodi FarhanLodi released this 14 Sep 16:11
· 1 commit to main since this release

EasyOcrSharp 3.1.1

Mostly accuracy, correctness and GPU fixes, plus a large update to the document-structure engine behind
AnalyzeDocumentAsync. No public type or member was removed or renamed. A few AnalyzeDocumentAsync
defaults changed; each one is listed below with the setting that restores the old behaviour.

📦 Packages

Package Version
EasyOcrSharp 3.1.1
EasyOcrSharp.Gpu 3.1.1
EasyOcrSharp.Cli (dotnet tool) 3.1.1
dotnet add package EasyOcrSharp --version 3.1.1
dotnet add package EasyOcrSharp.Gpu --version 3.1.1   # NVIDIA CUDA
dotnet tool update -g EasyOcrSharp.Cli --version 3.1.1

✨ Highlights

  • EasyOcrSharp.Gpu now actually runs on the GPU. Portable builds and publishes were silently running on CPU (details below).
  • Plain OCR no longer merges whole paragraphs into one unreadable box on wide pages.
  • Better document analysis:
    • whole-page OCR matched to layout blocks
    • XY-Cut++ reading order
    • seal (stamp) text recovery
    • table cells keep their line breaks in Word and Excel exports
  • New GPU diagnostics: ActiveExecutionProvider, OcrResult.ExecutionProvider and GetRuntimeInfo() tell you where inference really runs and why it fell back to CPU.

🐛 Fixes

GPU

  • EasyOcrSharp.Gpu did not use the GPU for portable builds and publishes. EasyOcrSharp depends on the CPU ONNX Runtime package and EasyOcrSharp.Gpu adds the GPU one. Both ship onnxruntime.dll / libonnxruntime.so at the same path, and NuGet deployed the CPU copy. The CUDA provider could never load, Auto picked CPU, and nothing was logged. The package now includes a build step that deploys the GPU runtime after build and publish. It is verified for portable build, rebuild, portable publish and -r win-x64 publish. To opt out:

    <EasyOcrSharpGpuPreferGpuRuntime>false</EasyOcrSharpGpuPreferGpuRuntime>
  • OcrResult.UsedGpu reported the accelerator that was requested, not the one used. When CUDA failed to attach, OCR fell back to CPU while UsedGpu stayed true. It now reflects what actually ran. The following use the actual provider too:

    • the easyocr.gpu trace tag
    • the easyocr.provider metric tag
    • the health check's executionProvider
    • CLI info / scan / pdf output

    EasyOcrService.UseGpu is unchanged: it still means the selected accelerator.

  • GPU fallback messages now point at the real cause:

    • a missing package
    • a GPU runtime displaced by the CPU one
    • a CUDA major-version mismatch, naming the missing library (e.g. cublasLt64_13.dll)
    • a missing cuDNN 9
    • no NVIDIA GPU present

    Without an ILogger, the explanation is written once to standard error.

Plain OCR

  • Whole paragraphs could collapse into one box. On wide pages, the tilted-line rule chained each line onto the line above, and the recognizer read the whole block as noise. Stacked lines now stay separate, and gently tilted lines still join.
  • Arabic-script output (ar, fa, ur, ug) is reordered for display, as Python EasyOCR does; it previously came back visually reversed. ⚠️ This changes the returned text for those languages.
  • Large multi-page images are no longer rejected by a new decoder default in EasyImageSharp 1.1.0 when your own MaxImagePixels / frame limits allow them.
  • The model download limit is raised from 512 MB to 2 GB, so the full-precision handwriting model (HandwritingOptions { Quantize = false }, ~1.11 GB) can download.

Document preprocessing (PreprocessingOptions)

  • DocumentUnwarp had two bugs. It fed the UVDoc model RGB instead of BGR, and it blurred the page through a fixed 488×712 resize. It now runs at the page's own resolution (longest side capped at 2000 px), and OCR confidence after unwarp improved on every page measured. Unwarp is slower on large pages as a result.
  • DocumentOrientation keeps its whole-page input on purpose. PaddleX's center-crop variant was measured to misclassify multi-column pages (383 of 400 correct vs 395 of 400).

📄 Document analysis (AnalyzeDocumentAsync)

The built-in PP-StructureV3 engine now matches PaddleOcrNet 2.1.0 (Python PaddleOCR 3.x parity):

  • Whole-page OCR: the page is OCR'd once and each line is assigned to its layout block. Lines that straddle two blocks are re-recognized per block, and inline formulas are spliced in as $…$.
  • XY-Cut++ reading order:
    • headers come first and footers last;
    • titles and figures are placed by distance;
    • right-to-left documents keep direction-aware ordering.
  • Layout clean-up: per-class confidence thresholds and merge rules from PP-StructureV3.yaml, plus NMS.
  • Seals: polygon detection and curved-text straightening, with a plain-OCR fallback, so stamp text is no longer dropped.
  • Tables:
    • multi-line cells keep their line breaks, which survive into DOCX and XLSX;
    • ToHtml() renders real tables instead of fallback text;
    • sideways tables are uprighted;
    • SLANeXt cell positions are corrected.
  • Markdown: new MarkdownRenderOptions. Page furniture (headers, footers, page numbers, footnotes) is omitted by default, and consecutive text merges into paragraphs.
  • Accuracy: correct BGR model inputs, vertical-text rotation, near-native detection resolution, better resampling, and more.
  • Language routing: ru / uk / be use the East-Slavic recognizer, and ja uses the PP-OCRv5 default recognizer.

⚠️ Changed defaults (document analysis only)

Setting Before Now Restore previous behaviour
DocumentAnalysisOptions.LayoutNms false true LayoutNms = false
DocumentAnalysisOptions.ReadingOrder (Auto) model's predicted order XY-Cut++ ReadingOrder = DocumentReadingOrder.Model
Markdown export every block rendered page headers/footers/page numbers/footnotes omitted pass a MarkdownRenderOptions that keeps them

Plain ExtractText* OCR options and defaults are unchanged.

➕ Added

  • EasyOcrService.ActiveExecutionProvider: the provider inference is running on right now.
  • OcrResult.ExecutionProvider: the provider that produced this result.
  • EasyOcrService.GetRuntimeInfo(): returns OcrRuntimeInfo, covering the ONNX Runtime version, available providers, requested/resolved/active provider, GPU probe and hint. ToString() gives a ready-to-log report.
  • EasyOcrServiceOptions.DetectorModelPath: load a CRAFT detector ONNX file from disk, with no download and no checksum. Combine it with custom recognizers and ModelDownloadOptions.Offline to run fully offline.
  • MarkdownRenderOptions for structure Markdown export.

⬆️ Dependencies

  • EasyImageSharp 1.1.0
  • Microsoft.ML.OnnxRuntime / .Gpu 1.30.0
  • Microsoft.Extensions.* 10.0.12

🔧 Upgrade notes

  • GPU users need CUDA 13 + cuDNN 9. ONNX Runtime 1.27 and later target CUDA 13.
    • CUDA 12 machines: install the CUDA 13 runtime alongside CUDA 12 (the two coexist), or use DirectML on Windows.
    • Don't pin an older ONNX Runtime: EasyOcrSharp is compiled against 1.30 and will fail to load with an older one.
    • Checking a CPU fallback: see Diagnosing a CPU fallback in the README.
  • If you set ExcludeAssets="native" on Microsoft.ML.OnnxRuntime to work around the GPU issue, you can remove it.

Known limitations

  • English in document analysis uses the default PP-OCRv5 recognizer, which covers Chinese, English and Japanese. The dedicated English recognizer will be enabled once its model files are published to the EasyOcrSharp model repository.

Full changelog: CHANGELOG.md