Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

error of "Incorrect shape" in example/cpp/image-classification-predict.cc #2709

Closed
VincentChong123 opened this issue Jul 15, 2016 · 10 comments
Closed

Comments

@VincentChong123
Copy link

VincentChong123 commented Jul 15, 2016

prediction using image-classification-predict.cc return error below for my input 224x224 color image, which complies with size setting in image-classification-predict.cc. Please kindly advise.

[src/c_api/c_predict_api.cc]MXPredCreatePartialOut(177):CHECK
[00:17:33] /N/software/mxnet/mxnet-master/dmlc-core/include/dmlc/logging.h:235: [00:17:33] src/operator/./concat-inl.h:152: Check failed: (dshape[j]) == (tmp[j]) Incorrect shape[2]: (1,320,15,15). (first input shape: (1,576,14,14)

Thanks!

@stardut
Copy link

stardut commented Jul 15, 2016

I met the error too.You can change your data_shape's value to solve it. What is your data_shape's value?

@VincentChong123
Copy link
Author

Hi @stardust, thanks for your support.
data_shape's equivalence, input_shape_data[4] = {1, 3, 224,224} as set below

   //image-classification-predict.cc
    // Image size and channels
    int width  = 224;
    int height = 224;
    int channels = 3;

    const mx_uint input_shape_indptr[2] = { 0, 4 };
    // ( trained_width, trained_height, channel, num)
    const mx_uint input_shape_data[4] = { 1,
                                        static_cast<mx_uint>(channels),
                                        static_cast<mx_uint>(width),
                                        static_cast<mx_uint>(height) };
    PredictorHandle out = 0;  // alias for void *

    //-- Create Predictor
    MXPredCreate((const char*)json_data.GetBuffer(),
                 (const char*)param_data.GetBuffer(),
                 static_cast<size_t>(param_data.GetLength()),
                 dev_type,
                 dev_id,
                 num_input_nodes,
                 input_keys,
                 input_shape_indptr,
                 input_shape_data,
                 &out);

@taoari
Copy link
Contributor

taoari commented Jul 16, 2016

I think this is caused by the pooling behavior with 3x3/2 structures. This affects the CaffeNet, GoogleNet, Inception-BN models, but you can try VGG16, or ResNet50. They work good.

I did not notice this issue, and opened another similar issue #2718 , I think the reasons are the same. Hope that people will quickly fix this soon.

Or you can revert to the version tagged 20160531, it works good.

@VincentChong123
Copy link
Author

@taoari, thanks. Will try and report soon.
On Jul 16, 2016 1:02 PM, "taoari" [email protected] wrote:

I think this is caused by the pooling behavior with 3x3/2 structures. This
affects the CaffeNet, GoogleNet, Inception-BN models, but you can try
VGG16, or ResNet50. They work good.

I did not notice this issue, and opened another similar issue #2718
#2718 , I think the reasons are the
same. Hope that people will quickly fix this soon.

Or you can revert to the version tagged 20160531, it works good.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#2709 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AQyyHLZfvA3rPntuGfTL9n5QnspLvDbfks5qWGXUgaJpZM4JNAcK
.

@VincentChong123
Copy link
Author

VincentChong123 commented Jul 17, 2016

Hi @taoari, same error for inception_bn at mxnet-20160531 + 20160713's sub-modules (dmlc-core, ps-lite, ms-shadow). Will check with VGG16, or ResNet50

@taoari
Copy link
Contributor

taoari commented Jul 17, 2016

@weishengchong In my case, it works. See #2718 for my description.

It is this PR #2585 that changes the behavior. When I revert to one commit before that PR, it also works well.

I am not using the C++ file image-classification-predict.cc, you can use the notebook predict-with-pretrained-model.ipynb for a quick check.

@VincentChong123
Copy link
Author

@taoari

This affects the CaffeNet, GoogleNet, Inception-BN models, but you can try VGG16, or ResNet50. They work good.

I confirmed image-classification-predict.cc + inception_v3 works good using model below
https://github.com/dmlc/mxnet-model-gallery/blob/master/imagenet-1k-inception-v3.md

@taoari
Copy link
Contributor

taoari commented Jul 19, 2016

@weishengchong Maybe, but Inception_BN does not work. I did not try Inception-V3 yet.

3x3/2 pooling behavior is changed, it does not mean that models using 3x3/2 will not work.

For example, ResNet50 will behave like 112->55->28, while in He's paper it should work like 112->56->28. But ResNet50 still runs, and the final results might slightly different. I am not sure to what degree it will hurts the final accuracy.

@itijyou
Copy link

itijyou commented Jul 26, 2016

What about using the 3x3/2 pooling with pad=1? Pre-trained models may still degrade in accuracy though. There seems an offset of one pixel between this implementation and the previous.

@phunterlau
Copy link
Contributor

This issue is closed due to lack of activity in the last 90 days. Feel free to reopen if this is still an active issue. Thanks!

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

No branches or pull requests

5 participants