Skip to content

Releases: sdcb/SimdGcdrNet

Release list

v1.0.0

Choose a tag to compare

@sdcb sdcb released this 14 Oct 12:11

First release.

Package Version License
Sdcb.SimdGcdrNet 1.0.0 Apache-2.0
Sdcb.SimdGcdrNet.Models 1.0.0 MIT (upstream GCDRNet weights)
dotnet add package Sdcb.SimdGcdrNet
dotnet add package Sdcb.SimdGcdrNet.Models
using GcdrEnhancer enh = GcdrEnhancer.FromBytes(GcdrModels.GcNet, GcdrModels.DrNet, GcdrBackend.Auto);
byte[] dst = enh.Enhance(bgr, width, height);

English

Document shadow removal in pure C# — no onnxruntime.

A pure C# implementation of GCDRNet (IEEE TAI 2023): removes hand shadows, uneven lighting and bleed-through from phone photos of documents.

  • Zero inference-engine dependency: built-in ONNX reader, graph compiler (constant folding, operator fusion, arena planning) and runtime; no native binaries
  • CPU: AVX-512 / AVX2 / SSE / scalar on x64, NEON on arm64, SIMD128 on browser-wasm
  • GPU: Vulkan (Windows / Linux / Android), Metal (macOS Apple Silicon, pure C# P/Invoke)
  • Fast: ~9.6 ms end to end for 1600×1152 on an RTX 3080 Ti (PyTorch inference alone: 30.5 ms)
  • Easy to plug in: Bgr24 / Rgb24 / Bgra32 / Rgba32 buffers from OpenCvSharp, SkiaSharp, ImageSharp or System.Drawing; any stride, in place; thread-safe; Native AOT compatible
  • Useful before OCR: on a page with heavy bleed-through, OCR returned 56 lines (mostly the back of the page) before enhancement and the 14 real lines after (with SimdPaddleOCR)

Requires .NET 10 (net10.0).

中文

拍照文档一键去阴影:纯 C# 实现 GCDRNet,不依赖 onnxruntime。

纯 C# 实现 GCDRNet(IEEE TAI 2023),去掉手机拍照文档里的手影、光照不均和背面透字,输出接近扫描件的效果。

  • 不依赖任何推理引擎:自带 ONNX 解析、图编译(常量折叠、算子融合、内存 arena 规划)和推理引擎,没有原生 DLL
  • CPU 按指令集分档:x64 有 AVX-512 / AVX2 / SSE / 标量,ARM64 走 NEON,浏览器 WASM 走 SIMD128
  • GPU 加速:Windows、Linux 和 Android 走 Vulkan;macOS(Apple Silicon)走 Metal,纯 C# P/Invoke 实现
  • 性能:RTX 3080 Ti 上 1600×1152 一张图端到端约 9.6 ms(含上传、下载和前后处理),PyTorch 光推理就要 30.5 ms
  • 易于接入:支持 OpenCvSharp、SkiaSharp、ImageSharp、System.Drawing 的 Bgr24 / Rgb24 / Bgra32 / Rgba32,任意 stride、原地处理,线程安全,兼容 Native AOT
  • 适合 OCR 预处理:示例图背面透字严重,直接 OCR 识别出 56 行(大部分是背面乱码),增强后交给 SimdPaddleOCR 只得到正面真实的 14 行

需要 .NET 10。


The attached packages were built by CI (test workflow, green on this commit); the run summary has the cross-platform smoke and benchmark report.