ResNet error datum_height == data_mean_.height() (256 vs. 224) by using ResNet_mean.binaryproto

304 views
Skip to first unread message

Z.L

unread,
Apr 2, 2017, 11:13:28 PM4/2/17
to Caffe Users
Hi all,

when I train ResNet-50, I got the error as:


F0402 21:53:20.098677 35553 data_transformer.cpp:63] Check failed: datum_height == data_mean_.height() (256 vs. 224) 


when using ResNet_mean.binaryproto. The input data layer is following:


   1 name: "ResNet-50"

   2 layer {

   3   name: "resnet_50"

   4   type: "Data"

   5   top: "data"

   6   top: "label"

   7   include {

   8     phase: TRAIN

   9   }

  10   transform_param {

  11     mirror: true

  12     crop_size: 224

  13     mean_file: "../ResNet_mean.binaryproto"

  14     #mean_file: "../imagenet_mean.binaryproto"

  15   }

  16   data_param {

  17     source: "../ilsvrc12_train_lmdb/"

  18     batch_size: 16

  19     backend: LMDB

  20   }

  21 }

  22 layer {

  23   name: "resnet_50"

  24   type: "Data"

  25   top: "data"

  26   top: "label"

  27   transform_param {

  28     crop_size: 224

  29     mean_value: 104

  30     mean_value: 117

  31     mean_value: 123

  32     mirror: true

  33   }

  34  include {

  35     phase: TEST

  36   }

  37   data_param{

  38         source: "../ilsvrc12_val_lmdb/"

  39         batch_size:25

  40         backend: LMDB

  41         }

  42 }


However, when I used imagenet_mean.binaryproto, it works well. So I use python to read imagenet_mean.binaryproto and ResNet_mean.binaryproto file, I found:

imagenet_mean.binaryproto:  numpyarray data type with data shape (1, 3, 256, 256)

ResNet_mean.binaryproto: (1, 3, 224, 224)


It seems that when using mean binary file, caffe first subtracts mean value from original image and then do the crop. But when I use ResNet_mean.binaryproto, which 3*224*224, not matching input image size 3*256*256.


Does anyone have the same problem and how do you solve this? Thank you so much for your help.


Z.L






Cat

unread,
Mar 8, 2018, 12:12:46 PM3/8/18
to Caffe Users
I'm not sure if this helps but if you are finetuning on the ResNet-50 caffemodel, your images need to be 224x224. That means that your mean file will indicate this as well. Images in the ImageNet dataset are 256x256, which is indicated in their mean file by 3x256x256.

So it's got to do with your images and how you crop them I believe.


Hope this helps,
Cat
Reply all
Reply to author
Forward
0 new messages