[CVCUDA] Vision Processor Python API and Tutorial (#1394)

* bind success

* bind success fix

* FDMat pybind, ResizeByShort pybind

* FDMat pybind, ResizeByShort pybind, remove initialized_

* override BindProcessorManager::Run in python is available

* PyProcessorManager done

* vision_pybind fix

* manager.py fix

* add tutorials

* remove Apply() bind

* remove Apply() bind and fix

* fix reviewed problem

* fix reviewed problem

* fix reviewed problem readme

* fix reviewed problem readme etc

* apply return outputs

* nits

* update readme

* fix FDMatbatch

* add op pybind: CenterCrop, Pad

* add op overload for pass FDMatBatch

---------

Co-authored-by: Wang Xinyu <shaywxy@gmail.com>
This commit is contained in:
guxukai
2023-03-10 14:42:32 +08:00
committed by GitHub
parent cb7c8a07d4
commit c6480de736
22 changed files with 530 additions and 34 deletions

View File

@@ -0,0 +1,42 @@
中文 | [English](README.md)
# 多硬件图像处理库
多硬件图像处理库Vision Processor可用于实现模型的预处理、后处理等图像操作底层封装了多个第三方图像处理库包括
- OpenCV用于通用CPU图像处理
- FlyCV主要针对ARM CPU加速
- CV-CUDA用于NVIDIA GPU
## C++
待编写
## Python
Python API目前支持的算子如下
- ResizeByShort
- NormalizeAndPermute
用户可通过继承PyProcessorManager类实现自己的图像处理模块。基类PyProcessorManager实现了GPU内存管理、CUDA stream管理等用户仅需要实现apply()函数,在其中调用多硬件图像处理库中的算子、实现处理逻辑即可,具体实现可参考示例代码。
### 示例代码
- [Python示例](python)
### CV-CUDA与OpenCV性能对比
CPU: Intel(R) Xeon(R) Gold 6271C CPU @ 2.60GHz
GPU: T4
CUDA: 11.6
Processing logic: Resize -> NormalizeAndPermute
Warmup 100 roundstested 1000 rounds and get avg. latency.
| Input Image Shape | Target shape | Batch Size | OpenCV | CV-CUDA | Gain |
| ----------- | -- | ---------- | ------- | ------ | ------ |
| 1920x1080 | 640x360 | 1 | 1.1572ms | 0.9067ms | 16.44% |
| 1280x720 | 640x360 | 1 | 2.7551ms | 0.5296ms | 80.78% |
| 360x240 | 640x360 | 1 | 3.3450ms | 0.2421ms | 92.76% |