Sdcb.PaddleInference
2.4.1.3
Prefix Reserved
See the version list below for details.
dotnet add package Sdcb.PaddleInference --version 2.4.1.3
NuGet\Install-Package Sdcb.PaddleInference -Version 2.4.1.3
<PackageReference Include="Sdcb.PaddleInference" Version="2.4.1.3" />
paket add Sdcb.PaddleInference --version 2.4.1.3
#r "nuget: Sdcb.PaddleInference, 2.4.1.3"
// Install Sdcb.PaddleInference as a Cake Addin #addin nuget:?package=Sdcb.PaddleInference&version=2.4.1.3 // Install Sdcb.PaddleInference as a Cake Tool #tool nuget:?package=Sdcb.PaddleInference&version=2.4.1.3
PaddleSharp ๐
๐ .NET Wrapper for PaddleInference
C API, include PaddleOCR ๐, PaddleDetection ๐ฏ, Rotation Detector ๐, 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
).
NuGet Packages/Docker Images ๐ฆ
Release notes ๐
Please checkout this page ๐.
Infrastructure packages ๐๏ธ
Note: Linux does not need a native binding NuGet
package like windows(Sdcb.PaddleInference.runtime.win64.mkl
), instead, you can/should based from a Dockerfile ๐ณ to development:
Paddle Inference GPU package ๐ฎ
Since GPU package are too large(>1.5GB), I cannot publish a NuGet package to nuget.org, there is a limitation of 250MB when upload to Github, there is some related issues to this:
- https://github.com/PaddlePaddle/Paddle/issues/43874 โ
- https://github.com/NuGet/Home/issues/11706#issuecomment-1167305006 โ
However, you're good to build your own GPU nuget package using 01-build-native.linq
๐ ๏ธ.
Here is the GPU package that I compiled (not from Baidu official) ๐ ๏ธ: | NuGet Package ๐ผ | Version ๐ | Description ๐ | | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- | | cuda117_cudnn84_tr84_sm86 | | win64/CUDA 11.7/cuDNN 8.4/TensorRT 8.4/sm86 binding ๐ | | cuda102_cudnn76_sm61_75 | | win64/CUDA 10.2/cuDNN 7.6/sm61+sm75 binding ๐ | | cuda116_cudnn84_sm86_onnx | | win64/CUDA 11.6/cuDNN 8.4/sm86/onnx binding ๐ |
PaddleOCR packages ๐
Rotation Detection packages (part of PaddleCls) ๐
NuGet Package ๐ผ | Version ๐ | Description ๐ |
---|---|---|
Sdcb.RotationDetector | RotationDetector library(based on Sdcb.PaddleInference) โ๏ธ |
PaddleDetection packages ๐ฏ
NuGet Package ๐ผ | Version ๐ | Description ๐ |
---|---|---|
Sdcb.PaddleDetection | PaddleDetection library(based on Sdcb.PaddleInference) โ๏ธ |
Usage ๐
- PaddleOCR: PaddleOCR ๐
- PaddleDetection: PaddleDetection ๐
FAQ โ
Why my code runs good in my windows machine, but DllNotFoundException in other machine: ๐ป
Please ensure the latest Visual C++ Redistributable was installed in
Windows
(typically it should automatically installed if you haveVisual 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">
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()
๐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:
- (for Windows) Install the package:
Sdcb.PaddleInference.runtime.win64.cuda*
instead ofSdcb.PaddleInference.runtime.win64.mkl
, do not install both. ๐ฆ - Install CUDA from NVIDIA, and configure environment variables to
PATH
orLD_LIBRARY_PATH
(Linux) ๐ง - Install cuDNN from NVIDIA, and configure environment variables to
PATH
orLD_LIBRARY_PATH
(Linux) ๐ ๏ธ - Install TensorRT from NVIDIA, and configure environment variables to
PATH
orLD_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! ๐
TensorRT ๐
To use TensorRT, just specify PaddleDevice.Gpu().And(PaddleDevice.TensorRt("shape-info.txt"))
instead of PaddleDevice.Gpu()
to make it work. ๐ก
Please be aware, this shape info text file **.txt
is bound to your model. Different models have different shape info, so if you're using a complex model like Sdcb.PaddleOCR
, you should use different shapes for different models like this:
using PaddleOcrAll all = new(model,
PaddleDevice.Gpu().And(PaddleDevice.TensorRt("det.txt")),
PaddleDevice.Gpu().And(PaddleDevice.TensorRt("cls.txt")),
PaddleDevice.Gpu().And(PaddleDevice.TensorRt("rec.txt")))
{
Enable180Classification = true,
AllowRotateDetection = true,
};
In this case:
DetectionModel
will usedet.txt
๐180DegreeClassificationModel
will usecls.txt
๐RecognitionModel
will userec.txt
๐ก
NOTE ๐:
The first round of TensorRT
running will generate a shape info **.txt
file in this folder: %AppData%\Sdcb.PaddleInference\TensorRtCache
. It will take around 100 seconds to finish TensorRT cache generation. After that, it should be faster than the general GPU
. ๐
In this case, if something strange happens (for example, you mistakenly create the same shape-info.txt
file for different models), you can delete this folder to generate TensorRT cache again: %AppData%\Sdcb.PaddleInference\TensorRtCache
. ๐๏ธ
Thanks & Sponsors ๐
- ๆทฑๅณ-้ฑๆๆพ
- iNeuOSๅทฅไธไบ่็ฝๆไฝ็ณป็ป๏ผhttp://www.ineuos.net
Contact ๐
QQ group of C#/.NET computer vision technical communication (C#/.NET่ฎก็ฎๆบ่ง่งๆๆฏไบคๆต็พค): 579060605
Product | Versions 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 was computed. 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. |
.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. |
-
.NETFramework 4.5
- No dependencies.
-
.NETStandard 2.0
- System.Text.Encoding.CodePages (>= 6.0.0)
-
net6.0
- No dependencies.
NuGet packages (10)
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) |
|
Wlkr.SafePaddleOCR
ๅบไบPaddleSharp.PaddleOCR่ฎพ่ฎก็็บฟ็จๅฎๅ จๆจกๆฟ๏ผ็คบไพ๏ผ SafePaddleOCR safePaddleOCR = new SafePaddleOCR(); string imgPath = @"DimTechStudio-Logo.png"; var res = safePaddleOCR.Run(imgPath); Console.WriteLine($"res: {res.data.Text}"); |
|
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 |
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
|
|
sdcb/PaddleSharp
.NET/C# binding for Baidu paddle inference library and PaddleOCR
|
Version | Downloads | Last updated |
---|---|---|
2.5.0.1 | 18,076 | 8/5/2023 |
2.5.0 | 804 | 8/4/2023 |
2.5.0-preview.3 | 216 | 7/10/2023 |
2.5.0-preview.1 | 136 | 7/6/2023 |
2.4.1.4 | 1,984 | 6/30/2023 |
2.4.1.3 | 3,926 | 6/17/2023 |
2.4.1.3-preview.3 | 90 | 6/16/2023 |
2.4.1.2 | 1,241 | 5/3/2023 |
2.4.1.1 | 820 | 3/31/2023 |
2.4.0 | 3,403 | 12/8/2022 |
2.4.0-rc.2 | 104 | 12/7/2022 |
2.3.2 | 3,106 | 9/10/2022 |
2.3.1 | 3,939 | 8/1/2022 |
2.3.0 | 1,539 | 6/27/2022 |
2.2.2 | 2,687 | 2/18/2022 |