# cuda-image-preprocess **Repository Path**: gfb1986144783/cuda-image-preprocess ## Basic Information - **Project Name**: cuda-image-preprocess - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-01-09 - **Last Updated**: 2025-01-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Cuda编程加速图像预处理 ## 项目简介 - 基于 `cuda` 和 `opencv` 环境 - **目标:** - 单独使用,以加速图像处理操作; - **结合 TensorRT 使用,进一步加快推理速度** ## 加速效果 - 这里对比 `Deeplabv3+ ` 使用 `cuda` 预处理前后的 tensorrt 推理速度 - 未使用cuda图像预处理的代码,可参考作者的另一个 [tensorrt](https://github.com/emptysoal/tensorrt-experiment) 的项目: | Deeplabv3+ | FP32 | FP16 | INT8 | | :-----------: | :------------: | :------------: | :------------: | | C++图像预处理 | 22 ms | 12 ms | 10 ms | | CUDA图像预处理 | 15 ms | 5 ms | 3 ms | - 对比 `YOLOv5-v5.0` 使用 `cuda` 预处理前后的 tensorrt 推理速度 | YOLOv5-v5.0 | FP32 | FP16 | INT8 | | :-----------: | :------------: | :------------: | :------------: | | C++图像预处理 | 12 ms | 8 ms | 6 ms | | CUDA图像预处理 | 6 ms | 3 ms | 3 ms | YOLOv5 TensorRT 推理代码源自作者其他的项目 [C++预处理](https://github.com/emptysoal/TensorRT-v8-YOLOv5-v5.0/tree/main) [CUDA预处理](https://github.com/emptysoal/TensorRT-v8-YOLOv5-v5.0/tree/cpp-preproc) ## 文件说明 ```bash project dir ├── bgr2rgb # 实现BGR转RGB的cuda加速 | ├── Makefile | └── bgr2rgb.cu ├── bilinear # 实现双线性插值的cuda加速 | ├── Makefile | └── resize.cu ├── hwc2chw # 实现通道维度前置的cuda加速 | ├── Makefile | └── transpose.cu ├── normalize # 实现归一化的cuda加速 | ├── Makefile | └── normal.cu ├── preprocess # 汇总以上的图像处理(不是简单的拼接),实现常用的图像预处理,之后输入到网络当中 | ├── Makefile | └── preprocess.cu ├── union_tensorrt # 将上述的图像预处理,结合TensorRT一起使用,对比推理加速效果 | ├── Makefile | ├── preprocess.cu | ├── preprocess.h | └── trt_infer.cpp # 用于模型推理 └── lena.jpg # 用于测试的图片 ``` ## 使用说明 ### 图像加速单一操作: - 对于目录:bgr2rgb、bilinear、hwc2chw、normalize,实现单一功能上的图像操作加速 - 使用测试: ```bash cd