Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract 最后的fc blob出来的Mat是empty的 #396

Closed
frankieGitHub opened this issue May 11, 2018 · 9 comments
Closed

extract 最后的fc blob出来的Mat是empty的 #396

frankieGitHub opened this issue May 11, 2018 · 9 comments

Comments

@frankieGitHub
Copy link

Hi ,
我使用的是caffe模型转为ncnn的模型,使用example里的squeezencnn,可以正常加载模型。
在运行时,也正常输入in Mat,可是extract最后的FC层的top blob确是空的,如果往前面几层是有数据的,请问,这种问题应该如何排查,谢谢。

@PipeBlack
Copy link

什么平台下的(Android ios 或pc),能把你喂数据到提取数据那几句代码发一下吗?

@frankieGitHub
Copy link
Author

Android平台的。
ncnn::Mat in;
{
AndroidBitmapInfo info;
AndroidBitmap_getInfo(env, bitmap, &info);
int width = info.width;
int height = info.height;

    void* indata;
    AndroidBitmap_lockPixels(env, bitmap, &indata);

    in = ncnn::Mat::from_pixels((const unsigned char*)indata, ncnn::Mat::PIXEL_RGBA2BGR, 112, 96);

    AndroidBitmap_unlockPixels(env, bitmap);
}

// squeezenet
//std::vector<float> cls_scores;
float cls_scores[256] = {0.0};
{
    const float mean_vals[3] = {127.5, 127.5, 127.5};
    const float normal_val = 0.0078125;
    in.substract_mean_normalize(mean_vals, &normal_val);

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

    ex.input(net_param_id::BLOB_data, in);
    ncnn::Mat out;
    ex.extract(net_param_id::BLOB_fc5, out);

    ///这里的out.w为0  ******
    __android_log_print(ANDROID_LOG_ERROR, "feature cout", "out.w is:%d", out.w);
    for (int j=0; j<out.w; j++)
    {
        cls_scores[j] = out[j];
    }

    env->SetFloatArrayRegion(feature, 0, 255, cls_scores);

@frankieGitHub
Copy link
Author

@PipeBlack

@PipeBlack
Copy link

@frankieGitHub
ex.extract(net_param_id::BLOB_fc5, out);
这个函数是有返回值的,你打出来看一下是多少?
你是用caffe2ncnn、ncnn2mem自己转的吗?编译的vs版本是哪一个?
issue#391是我提的问题,不知道是不是同样的原因造成的

@frankieGitHub
Copy link
Author

@PipeBlack
返回值-100

@frankieGitHub
Copy link
Author

@PipeBlack 看样子现象是一样的

@frankieGitHub
Copy link
Author

@PipeBlack 你的问题找到原因了吗?

@PipeBlack
Copy link

PipeBlack commented May 12, 2018

@frankieGitHub
没。。
我以不同的方式得到Mat in喂进网络,还有ex.extract()返回0,但out.w也为0的情况。(我自己的代码问题)
出问题的原因在慢慢找
我更换了网络,没有出现同样的问题。

@PipeBlack
Copy link

@frankieGitHub 参考这个 https://github.com/Tencent/ncnn/wiki/cmake-打包-android-sdk
生成libncnn.a,取代从releases中下载的可以解决
make package这一句显示
make: *** No rule to make target 'package'. Stop.
issue#38说make package这句不需要

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants