ncnn Detection results always equal to 0

8wigbo56  于 2022-12-31  发布在  其他
关注(0)|答案(2)|浏览(122)
const float mean_vals[3] = {104.f, 117.f, 123.f};
        in.substract_mean_normalize(mean_vals, 0);

        ncnn::Extractor ex = squeezenet.create_extractor();
        ex.set_light_mode(true);
        ex.set_num_threads(4);

        ex.input(squeezenet_v1_1_param_id::BLOB_data, in);

        ncnn::Mat out;
        ex.extract(squeezenet_v1_1_param_id::BLOB_prob, out);

        __android_log_print(ANDROID_LOG_DEBUG, "SqueezeNcnn", "Output Channels : %d", out.c);

        cls_scores.resize(out.c);
        for (int j=0; j<out.c; j++)
        {
            const float* prob = out.channel(j);
            cls_scores[j] = prob[0];

            //cls_-scores[j] = out[j];
        }

The above code is implemented in Android Studio. I've printed out parameter "in", which is the correct image value, but output channel(out.c) = 0 and cls_scores = 0. The libncnn.a is compiled through

cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake
-DANDROID_ABI="arm64-v8a" -DANDROID_PLATFORM=android-21 -DCMAKE_INSTALL_PREFIX=/home/liuwen/ncnn_lib ..

Would anyone please give suggestions how this could happen, I've been stucking into this problem for a while. Thanks!

gfttwv5a

gfttwv5a1#

int inSucess = ex.input(squeezenet_v1_1_param_id::BLOB_data, in); __android_log_print(ANDROID_LOG_DEBUG, "SqueezeNcnn", "In Success : %d", inSucess);

2020-01-07 17:53:39.122 27269-27269/com.example.hellojni D/SqueezeNcnn: In Success : -1

After checking the correctness of ncnn::Mat, I'm not sure why loading ex.input the result is incorrect. (return 0 is success ; return -1 is not success)

zd287kbt

zd287kbt2#

This usually means that the model loading has already failed.
If you use xyz.param path, use Net::load_param(const char*) to load from param memory
If you use xyz.param memory, use Net::load_param_men(const char*) to load from param memory
If you use xyz.param.bin path, use Net::load_param_bin(const char*) to load from param memory
If you use xyz.param.bin memory, use Net::load_param(const unsigned char*) to load from param memory

相关问题