inference中preprocessor_detection.cpp 里的实现不完整,采用默认的feeds_size会出错
Created by: FibonacciSun
single_process函数的末尾处,撸数据的过程中,如果feeds_size不为2或者3,101行的pixel的初值不定(栈上的值),程序行为不确定 而文档里对feeds_size的说明如下,我很天真地地用了默认值
# 类型:optional int
# 含义: 输入张量的个数。大部分模型不需要设置。 默认值为1.
FEEDS_SIZE: 2
文档如下:
https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.1/inference/docs/configuration.md
for (int h = 0; h < rh; ++h) { 89 const uchar* uptr = im.ptr(h); 90 const float* fptr = im.ptr(h); 91 int im_index = 0; 92 for (int w = 0; w < rw; ++w) { 93 for (int c = 0; c < channels; ++c) { 94 int top_index = (c * rh + h) * rw + w; 95 float pixel; 96 if (_config->_feeds_size == 2) { // yolo v3 97 pixel = static_cast(uptr[im_index++]) / 255.0; 98 } else if (_config->_feeds_size == 3) { 99 pixel = fptr[im_index++]; 100 } 101 pixel = (pixel - pmean[c]) / pscale[c]; 102 data[top_index] = pixel; 103 } 104 } 105 } 106 return true; 107 }