Code Monkey home page Code Monkey logo

paddlexcsharp's Introduction

项目背景

百度飞桨团队开发了一款全流程深度学习模型开发工具:PaddleX,分为API版本和GUI版本。使用PaddleX可以低代码甚至零代码实现图像分类、目标检测、语义分割、实例分割等任务,非常适合于非计算机背景(如工业领域)的从业者完成深度学习开发。

为了更便捷地与多类传感器和上位系统通信、工业领域内上位机软件常常用C#来开发,但深度学习本身以C++和Python为主。因此,本Demo的目标就是基于PaddleX,打通深度学习C#部署的最后一步。

项目简介

本项目基于C#开发,可以驱动海康威视黑白相机、basler黑白/彩色相机,获取图像后使用PaddleX深度学习库,实现图像分类、目标检测和语义分割功能。

从功能层面,共分为三部分:

  • 本地单模型模式
    • 部署于本地服务器
    • 每次可调用一个相机
    • 加载一个深度学习模型,实现一种任务
  • 本地多模型模式
    • 部署于本地服务器
    • 每次可调用多个相机(目前支持2个)
    • 每个相机可独立加载一个深度学习模型,同步实现多种任务
  • 远程起服务模式
    • 部署于远程服务器
    • 通过gRPC方式,调用远程服务器

项目目录

  • PaddleXCsharp文件内容使用C#开发,实现本项目的基本功能
  • PaddleXDll为PaddleX提供的C++程序,用于编译DLL
  • gRPC_demo为远程起服务模式,使用python开发

使用方法

  1. 将项目克隆(下载)至本地
  2. 使用PaddleXDll文件下内容,编译可供C#下调用的DLL(这里为大家提供一份编译好的DLL,百度网盘链接,提取码:2luj)
  3. 将DLL文件添加至C#bin文件下
  4. 安装PaddleX,根据文档,训练出深度学习模型(注意,本demo仅支持PaddleX训练出的模型,不支持PaddlePaddle训练的模型)
  5. 连接相机,加载模型,启动测试

工作环境

  • CUDA 10.0
  • cudnn 7.5.0
  • Visual Studio 2019
  • OpenCvSharp3-AnyCPU
  • .NET Framework 4.7.2

经过测试,CUDA和CUDNN为其他版本时,可能会有问题,报错为:外部组件出现异常

演示示例

下图以目标检测为例,演示如何调用相机、加载模板检测模型,实现压力表的检测。

本地单模型模式

相机操作及推理

Alt text

Alt text

本地多模型模式

相机操作及推理

Alt text

Alt text

paddlexcsharp's People

Contributors

gt-acerzhang avatar likangyulky avatar yzl19940819 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

paddlexcsharp's Issues

可以提供目标检测部分的interface代码吗

本人新手,只希望导入paddleX训练后的模型通过C#来推理,请问可以提供目标检测的推理部分的代码吗?
另外工程文件缺少这三个引用不知道在哪下载
image
谢谢

在C#端无法正常使用GPU做推理

在C#端可以正常使用CPU加载模型与推理,但是使用GPU只能加载模型而不能正常推理,会提示如下错误信息。在C++环境下可以正常CPU和GPU的加载与推理,CPU与GPU的推理接口一样的。
image
image

image

W0206 01:15:36.804785 19100 device_context.cc:260] device: 0, cuDNN Version: 7.5.
引发的异常:“System.AccessViolationException”(位于 PaddleXCsharp.exe 中)
“System.AccessViolationException”类型的未经处理的异常在 PaddleXCsharp.exe 中发生
尝试读取或写入受保护的内存。这通常指示其他内存已损坏。

“PaddleXCsharp.exe”(CLR v4.0.30319: PaddleXCsharp.exe): 已加载“D:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Remote Debugger\x64\Runtime\Microsoft.VisualStudio.Debugger.Runtime.Desktop.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
程序“[2484] PaddleXCsharp.exe: 程序跟踪”已退出,返回值为 0 (0x0)。
程序“[2484] PaddleXCsharp.exe”已退出,返回值为 -1 (0xffffffff)。

系统环境,Windows 10,i5 9400f ,DDR4 24G,RTX 2070 8G,Visual Studio 2019

加载模型报错

加载模型报错:
运行模式为anycpu,另外X64、X86模式都不能通过编译。
可以打开相机采集图像,但是一点击“加载模型”选择模型存放路径,确认的时候就会报错。
P~%4YC1WI5)1C2Q7{`L@A
模型存放路径下文件情况:
Y{MU(BHS8L5DY8Q }S8UME9

模型加载

您好,我在选好导出来的模型时,执行这句 model = CreatePaddlexModel(ref modelType, modelPath, useGPU, useTrt, useMkl, mklThreadNum, gpuID, key, useIrOptim);报错:System.BadImageFormatException:“试图加载格式不正确的程序。 (异常来自 HRESULT:0x8007000B)” ,不知是啥情况,模型文件夹内包含__model__,params,model.yml三个文件

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.