YOLOv8-TensorRT icon indicating copy to clipboard operation
YOLOv8-TensorRT copied to clipboard

cv::dnn::blobFromImage(image, nchw, 1 / 255.f, size, cv::Scalar(0, 0, 0), true, false, CV_32F);函数耗时

Open whiteCupz opened this issue 1 year ago • 7 comments

使用后推理时间大幅提升,但是这行代码耗时最久,cv::dnn::blobFromImage(image, nchw, 1 / 255.f, size, cv::Scalar(0, 0, 0), true, false, CV_32F)。

whiteCupz avatar Nov 30 '23 08:11 whiteCupz

我看到 有别的做法 是写cuda 代码 ,全部用显卡运算。

ZJDATY avatar Jan 29 '24 11:01 ZJDATY

我看到 有别的做法 是写cuda 代码 ,全部用显卡运算。

是的,可以尝试warpaffinekernel.

triple-Mu avatar Mar 11 '24 03:03 triple-Mu

Hello , do u have any update about this code line ? the inference is running really fast around 1ms to 2 ms but blob functions add 10 to 18 ms which affects a lot.

eostos avatar Apr 12 '24 02:04 eostos

Hello , do u have any update about this code line ? the inference is running really fast around 1ms to 2 ms but blob functions add 10 to 18 ms which affects a lot.

I will update a more quick cpu version the last few days.

triple-Mu avatar May 24 '24 15:05 triple-Mu

This pr improve preprocess hwc->nchw by opencv cv::split. Welcome to try it and give valuable feedback!

triple-Mu avatar Jun 04 '24 06:06 triple-Mu

@triple-Mu image 我如果还想添加这个处理 ,大佬可以写一下吗

image -= np.array([123.675, 116.28, 103.53], np.float32)
image /= np.array([58.395, 57.12, 57.375], np.float32)

ZJDATY avatar Jun 04 '24 06:06 ZJDATY

@triple-Mu image 我如果还想添加这个处理 ,大佬可以写一下吗

image -= np.array([123.675, 116.28, 103.53], np.float32)
image /= np.array([58.395, 57.12, 57.375], np.float32)

这个原版yolov8没有的吧? 你可以尝试在 convertTo中修改alpha和beta试试

triple-Mu avatar Jun 04 '24 06:06 triple-Mu