PaddlePaddle / PaddleVideo

Awesome video understanding toolkits based on PaddlePaddle. It supports video data annotation tools, lightweight RGB and skeleton based action recognition model, practical applications for video tagging and sport action detection.
Apache License 2.0
1.53k stars 380 forks source link

PPtsm V2 c++推理预处理过程 #614

Open fengyanWang opened 1 year ago

fengyanWang commented 1 year ago

参考工程中的cpp_infer中的预处理部分代码进行编写,结果预处理结果一直不对,其中通过保存CenterCrop后的图片与Python预处理结果对比是一致的,所以可以说明问题在Normalize和Permute函数中,还请大佬帮忙看看

预处理过程如下:

std::string img_path = "/data/local/tmp/pic_2.jpg"; //为了与Python对比,拿出其中一帧 cv::Mat img_data = cv::imread(img_path); cv::cvtColor(img_data, img_data, cv::COLOR_BGR2RGB);

cv::Mat resize_frame; Scale(img_data,resize_frame,256);

cv::Mat crop_frame; CenterCrop(resize_frame,crop_frame,224);

Normalize(&cropframe, inputMean, inputStd_, true);

std::vector inputtemp(1 3 inputHeight * inputWidth_,0.0f); Permute(&crop_frame, input_temp.data());

上述预处理中调用函数如附件所示: preprocess.zip

fengyanWang commented 1 year ago

有人能帮忙看下问题吗?

huangjun12 commented 1 year ago

有对比过Normalize、Permute操作的输出和对应python处理的diff嘛

flywheel1412 commented 1 year ago

训练中resize使用的pillow,c++推理使用的是opencv,这两个库resize后的结果有差异,有些数据上得到的推理结果差异还蛮大的