Sdcb.PaddleInference 3.0.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Sdcb.PaddleInference --version 3.0.0
                    
NuGet\Install-Package Sdcb.PaddleInference -Version 3.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sdcb.PaddleInference" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sdcb.PaddleInference" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Sdcb.PaddleInference" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Sdcb.PaddleInference --version 3.0.0
                    
#r "nuget: Sdcb.PaddleInference, 3.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Sdcb.PaddleInference&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Sdcb.PaddleInference&version=3.0.0
                    
Install as a Cake Tool

PaddleSharp 🌟 main QQ

English | 简体中文

💗 .NET Wrapper for PaddleInference C API, support Windows(x64) 💻, NVIDIA Cuda 10.2+ based GPU 🎮 and Linux(Ubuntu-22.04 x64) 🐧, currently contained following main components:

  • PaddleOCR 📖 support 14 OCR languages model download on-demand, allow rotated text angle detection, 180 degree text detection, also support table recognition 📊.
  • PaddleDetection 🎯 support PPYolo detection model and PicoDet model 🏹.
  • RotationDetection 🔄 use Baidu's official text_image_orientation_infer model to detect text picture's rotation angle(0, 90, 180, 270).
  • PaddleNLP ChineseSegmenter 📚 support PaddleNLP Lac Chinese segmenter model, supports tagging/customized words.
  • Paddle2Onnx 🔄 Allow user export ONNX model using C#.

NuGet Packages/Docker Images 📦

Release notes 📝

Please checkout this page 📄.

Infrastructure packages 🏗️

NuGet Package 💼 Version 📌 Description 📚
Sdcb.PaddleInference NuGet Paddle Inference C API .NET binding ⚙️

Native packages 🏗️

Package Version 📌 Description
Sdcb.PaddleInference.runtime.win64.mkl NuGet win64+mkldnn
Sdcb.PaddleInference.runtime.win64.openblas NuGet win64+openblas
Sdcb.PaddleInference.runtime.win64.openblas-noavx NuGet no AVX, for old CPUs
Sdcb.PaddleInference.runtime.win64.cu120-sm86-89 NuGet for NVIDIA 30/40 series
Sdcb.PaddleInference.runtime.win64.cu120-sm80 NuGet for NVIDIA A100/A10
Sdcb.PaddleInference.runtime.win64.cu120-sm61-75 NuGet for NVIDIA 10/20 series

Note: cu120 means CUDA 12.0, it's compiled in CUDA 12.0.1/cuDNN 8.9.7.29/Tensor RT 8.6.1.6 version.

Linux OS packages(preview):

Package Version 📌 Description
Sdcb.PaddleInference.runtime.linux-loongarch64 NuGet Loongnix GCC 8.2 Loongarch64
Sdcb.PaddleInference.runtime.linux64.mkl.gcc82 NuGet Linux-x64 GCC 8.2(tested in Ubuntu 22.04)

Be aware, as the Linux operating system cannot modify the value of LD_LIBRARY_PATH at runtime. If dependent dynamic libraries (such as libcommon.so) are loaded before the main dynamic library (such as libpaddle_inference_c.so), and also due to protobuf errors reported: https://github.com/PaddlePaddle/Paddle/issues/62670

Therefore, all NuGet packages for Linux operating systems are in a preview state, and I'm unable to resolve this issue. Currently, if you are using the NuGet package on Linux, you need to manually specify the LD_LIBRARY_PATH environment variable before running the program, using the following commands:

  • For x64 CPUs: export LD_LIBRARY_PATH=/<program directory>/bin/Debug/net8.0/runtimes/linux-x64/native:$LD_LIBRARY_PATH

  • For Loongson 5000 or above CPUs (linux-loongarch64): export LD_LIBRARY_PATH=/<program directory>/bin/Debug/net8.0/runtimes/linux-loongarch64/native:$LD_LIBRARY_PATH

Some of packages already deprecated(Version ⇐ 2.5.0): | Package | Version 📌 | Description | | --------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | | Sdcb.PaddleInference.runtime.win64.cuda102_cudnn76_tr72_sm61_75 | NuGet | win64/CUDA 10.2/cuDNN 7.6/TensorRT 7.2/sm61+sm75 | | Sdcb.PaddleInference.runtime.win64.cuda118_cudnn86_tr85_sm86_89 | NuGet | win64/CUDA 11.8/cuDNN 8.6/TensorRT 8.5/sm86+sm89 | | Sdcb.PaddleInference.runtime.win64.cuda117_cudnn84_tr84_sm86 | NuGet | win64/CUDA 11.7/cuDNN 8.4/TensorRT 8.4/sm86 | | Sdcb.PaddleInference.runtime.win64.cuda102_cudnn76_sm61_75 | NuGet | win64/CUDA 10.2/cuDNN 7.6/sm61+sm75 | | Sdcb.PaddleInference.runtime.win64.cuda116_cudnn84_sm86_onnx | NuGet | win64/CUDA 11.6/cuDNN 8.4/sm86/onnx |

Any other packages that starts with Sdcb.PaddleInference.runtime might deprecated.

Baidu packages were downloaded from here: https://www.paddlepaddle.org.cn/inference/master/guides/install/download_lib.html#windows

All Windows packages were compiled manually by me.

Baidu official GPU packages are too large(>1.5GB) to publish to nuget.org, there is a limitation of 250MB when upload to Github, there is some related issues to this:

But You're good to build your own GPU nuget package using 01-build-native.linq 🛠️.

Paddle Devices

  • Mkldnn - PaddleDevice.Mkldnn()

    Based on Mkldnn, generally fast

  • Openblas - PaddleDevice.Openblas()

    Based on openblas, slower, but dependencies file smaller and consume lesser memory

  • Onnx - PaddleDevice.Onnx()

    Based on onnxruntime, is also pretty fast and consume less memory

  • Gpu - PaddleDevice.Gpu()

    Much faster but relies on NVIDIA GPU and CUDA

    If you wants to use GPU, you should refer to FAQ How to enable GPU? section, CUDA/cuDNN/TensorRT need to be installed manually.

FAQ ❓

Why my code runs good in my windows machine, but DllNotFoundException in other machine: 💻

  1. Please ensure the latest Visual C++ Redistributable was installed in Windows (typically it should automatically installed if you have Visual Studio installed) 🛠️ Otherwise, it will fail with the following error (Windows only):

    DllNotFoundException: Unable to load DLL 'paddle_inference_c' or one of its dependencies (0x8007007E)
    

    If it's Unable to load DLL OpenCvSharpExtern.dll or one of its dependencies, then most likely the Media Foundation is not installed in the Windows Server 2012 R2 machine: <img width="830" alt="image" src="https://user-images.githubusercontent.com/1317141/193706883-6a71ea83-65d9-448b-afee-2d25660430a1.png">

  2. Many old CPUs do not support AVX instructions, please ensure your CPU supports AVX, or download the x64-noavx-openblas DLLs and disable Mkldnn: PaddleDevice.Openblas() 🚀

  3. If you're using Win7-x64, and your CPU does support AVX2, then you might also need to extract the following 3 DLLs into C:\Windows\System32 folder to make it run: 💾

    • api-ms-win-core-libraryloader-l1-2-0.dll
    • api-ms-win-core-processtopology-obsolete-l1-1-0.dll
    • API-MS-Win-Eventing-Provider-L1-1-0.dll

    You can download these 3 DLLs here: win7-x64-onnxruntime-missing-dlls.zip ⬇️

How to enable GPU? 🎮

Enable GPU support can significantly improve the throughput and lower the CPU usage. 🚀

Steps to use GPU in Windows:

  1. (for Windows) Install the package: Sdcb.PaddleInference.runtime.win64.cu120* instead of Sdcb.PaddleInference.runtime.win64.mkl, do not install both. 📦
  2. Install CUDA from NVIDIA, and configure environment variables to PATH or LD_LIBRARY_PATH (Linux) 🔧
  3. Install cuDNN from NVIDIA, and configure environment variables to PATH or LD_LIBRARY_PATH (Linux) 🛠️
  4. Install TensorRT from NVIDIA, and configure environment variables to PATH or LD_LIBRARY_PATH (Linux) ⚙️

You can refer to this blog page for GPU in Windows: 关于PaddleSharp GPU使用 常见问题记录 📝

If you're using Linux, you need to compile your own OpenCvSharp4 environment following the docker build scripts and the CUDA/cuDNN/TensorRT configuration tasks. 🐧

After these steps are completed, you can try specifying PaddleDevice.Gpu() in the paddle device configuration parameter, then enjoy the performance boost! 🎉

Thanks & Sponsors 🙏

Contact 📞

QQ group of C#/.NET computer vision technical communication (C#/.NET计算机视觉技术交流群): 579060605 alternate text is missing from this package README image

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (11)

Showing the top 5 NuGet packages that depend on Sdcb.PaddleInference:

Package Downloads
Sdcb.PaddleOCR

Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition)

HHO.LV.OCR

Library packed for OCR

Sdcb.PaddleDetection

Object Detection toolkit based on PaddlePaddle. It supports object detection, instance segmentation, multiple object tracking and real-time multi-person keypoint detection.

BotSharp.Plugin.PaddleSharp

Package Description

Wlkr.SafePaddleOCR

基于PaddleSharp.PaddleOCR设计的线程安全模板,示例: SafePaddleOCR safePaddleOCR = new SafePaddleOCR(); string imgPath = @"DimTechStudio-Logo.png"; var res = safePaddleOCR.Run(imgPath); Console.WriteLine($"res: {res.data.Text}");

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on Sdcb.PaddleInference:

Repository Stars
babalae/better-genshin-impact
📦BetterGI · 更好的原神 - 自动拾取 | 自动剧情 | 全自动钓鱼(AI) | 全自动七圣召唤 | 自动伐木 | 自动刷本 | 自动采集/挖矿/锄地 | 一条龙 | 全连音游 - UI Automation Testing Tools For Genshin Impact
SciSharp/BotSharp
AI Multi-Agent Framework in .NET
PavlikBender/ScreTran
Простой экранный переводчик, screen translator
Version Downloads Last Updated
3.0.1 550 6/23/2025
3.0.0 2,576 6/14/2025
2.5.0.1 44,392 8/5/2023
2.5.0 1,855 8/4/2023
2.5.0-preview.3 249 7/10/2023
2.5.0-preview.1 164 7/6/2023
2.4.1.4 2,072 6/30/2023
2.4.1.3 4,049 6/17/2023
2.4.1.3-preview.3 126 6/16/2023
2.4.1.2 1,299 5/3/2023
2.4.1.1 887 3/31/2023
2.4.0 3,626 12/8/2022
2.4.0-rc.2 144 12/7/2022
2.3.2 3,226 9/10/2022
2.3.1 4,064 8/1/2022
2.3.0 1,622 6/27/2022
2.2.2 2,841 2/18/2022