balancap / SSD-Tensorflow

Single Shot MultiBox Detector in TensorFlow
4.11k stars 1.89k forks source link

caffemodel conversion error:number of input channels does not match corresponding dimension of filter #106

Open lqf4py opened 7 years ago

lqf4py commented 7 years ago

I tried to convert my caffemodel file to tensorflow, but got an error...

Traceback (most recent call last): File "caffe_to_tensorflow.py", line 65, in tf.app.run() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 44, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "caffe_to_tensorflow.py", line 51, in main ssd_net.net(img_input, is_training=False) File "/home/oeasy/lqf/transmodels/SSD-Tensorflow/nets/ssd_vgg_300.py", line 155, in net scope=scope) File "/home/oeasy/lqf/transmodels/SSD-Tensorflow/nets/ssd_vgg_300.py", line 502, in ssd_net net = slim.conv2d(net, 128, [1, 1], scope='conv1x1') File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 177, in func_with_args return func(*args, current_args) File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/layers/layers.py", line 907, in convolution outputs = layer.apply(inputs) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.py", line 303, in apply return self.call(inputs, kwargs) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.py", line 273, in call outputs = self.call(inputs, **kwargs) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/convolutional.py", line 156, in call data_format=utils.convert_data_format(self.data_format, self.rank + 2)) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 619, in convolution num_spatial_dims])) ValueError: number of input channels does not match corresponding dimension of filter, 256 != 512

anyone knows what happend? Thank you !

w5688414 commented 6 years ago

I have the same problem like you, when I change my command code, it works fine, here is my code: CAFFE_MODEL=./models/VGGNet/VOC0712Plus/SSD_512x512/VGG_VOC0712Plus_SSD_512x512_iter_240000.caffemodel python caffe_to_tensorflow.py \ --model_name=ssd_512_vgg \ --num_classes=21 \ --caffemodel_path=${CAFFE_MODEL}

pay more attention to the model_name and the corresponding model's input is 512*512

Ethanwl commented 6 years ago

@lqf4py Have you solved the problem? @w5688414 I tried your method but there is still a erro Here is my code: CAFFE_MODEL=/home/MyWorkspace/SSD_512x512/VGG_LargeWider_SSD_512x512_iter_50000.caffemodel python caffe_to_tensorflow.py \ --model_name=ssd_512_vgg \ --num_classes=2 \ --caffemodel_path=${CAFFE_MODEL}

mihirbala commented 6 years ago

I am getting this error as well. I am running the code below. I have attached the deploy.prototxt if that helps. deploy.txt

CAFFE_MODEL=/workspace/snapshots/VGG_okutama_SSD_512x512_iter_20000.caffemodel python caffe_to_tensorflow.py --model_name=ssd_512_vgg --num_classes=2 --caffemodel_path=${CAFFE_MODEL}