tuan3w/visual_search

ValueError: Dimension 0 in both shapes must be equal, but are 2 and 1 From merging shape 1 with other shapes. for 'vgg16_default/rpn_cls_score_reshape/concat/concat_dim' (op: 'Pack') with input shapes: [1], [2], [1].

Closed this issue · 1 comments

Hi, all
Help! After downloading imagenet_weights and faster_rcnn_models from pre-trained model here, I run index_es.py like this:

export WEIGHT_PATH=/home/ceshi/search/visual_search/imagenet_weights/vgg16.weights
export MODEL_PATH=/home/ceshi/search/visual_search/faster_rcnn_models/vgg16_faster_rcnn_iter_70000.ckpt
export INPUT=/home/ceshi/search/visual_search/INPUT

python index_es.py --weight $WEIGHT_PATH --model_path $MODEL_PATH --input $INPUT

Got this error:

Loading caffe weights...
Done!
Traceback (most recent call last):
  File "index_es.py", line 104, in <module>
    sess=sess)
  File "/home/ceshi/search/visual_search/visual_search/extractor.py", line 53, in __init__
    tag='default', anchor_scales=anchors)
  File "/home/ceshi/search/visual_search/visual_search/lib/nets/vgg16.py", line 496, in create_architecture
    rois, cls_prob, bbox_pred = self._vgg16_from_imagenet(sess, training)
  File "/home/ceshi/search/visual_search/visual_search/lib/nets/vgg16.py", line 347, in _vgg16_from_imagenet
    rpn_cls_score_reshape = self._reshape_layer(rpn_cls_score, 2, "rpn_cls_score_reshape")
  File "/home/ceshi/search/visual_search/visual_search/lib/nets/vgg16.py", line 178, in _reshape_layer
    reshaped = tf.reshape(to_caffe, tf.concat(0, [[self._batch_size], [num_dim, -1], [input_shape[2]]]))
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 1061, in concat
    dtype=dtypes.int32).get_shape(
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 611, in convert_to_tensor
    as_ref=False)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 676, in internal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 937, in _autopacking_conversion_function
    return _autopacking_helper(v, inferred_dtype, name or "packed")
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 900, in _autopacking_helper
    return gen_array_ops._pack(elems_as_tensors, name=scope)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 1949, in _pack
    result = _op_def_lib.apply_op("Pack", values=values, axis=axis, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op
    op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2632, in create_op
    set_shapes_for_outputs(ret)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1911, in set_shapes_for_outputs
    shapes = shape_func(op)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1861, in call_with_requiring
    return call_cpp_shape_fn(op, require_shape_fn=True)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/common_shapes.py", line 595, in call_cpp_shape_fn
    require_shape_fn)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/common_shapes.py", line 659, in _call_cpp_shape_fn_impl
    raise ValueError(err.message)
ValueError: Dimension 0 in both shapes must be equal, but are 2 and 1
	From merging shape 1 with other shapes. for 'vgg16_default/rpn_cls_score_reshape/concat/concat_dim' (op: 'Pack') with input shapes: [1], [2], [1].

I also tried endernewton/tf-faster-rcnn, and the demo.py works ok. Which goes:

2017-09-15 08:51:59.013136: I tensorflow/core/common_runtime/gpu/gpu_device.cc:955] Found device 0 with properties:
name: Tesla K40m
major: 3 minor: 5 memoryClockRate (GHz) 0.745
pciBusID 0000:04:00.0
Total memory: 11.17GiB
Free memory: 10.92GiB
2017-09-15 08:51:59.013227: I tensorflow/core/common_runtime/gpu/gpu_device.cc:976] DMA: 0
2017-09-15 08:51:59.013270: I tensorflow/core/common_runtime/gpu/gpu_device.cc:986] 0:   Y
2017-09-15 08:51:59.013313: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Tesla K40m, pci bus id: 0000:04:00.0)
Loaded network output/res101/voc_2007_trainval+voc_2012_trainval/default/res101_faster_rcnn_iter_110000.ckpt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo for data/demo/000456.jpg
Detection took 2.319s for 300 object proposals
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo for data/demo/000542.jpg
Detection took 0.659s for 151 object proposals
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo for data/demo/001150.jpg
Detection took 0.724s for 178 object proposals
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo for data/demo/001763.jpg
Detection took 0.844s for 224 object proposals
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo for data/demo/004545.jpg
Detection took 0.413s for 300 object proposals

environment:
os: Ubuntu 16.04
tf: tensorflow-gpu (1.3.0) 1.2.0 also does not work
Python: 2.7.12
gpu: Tesla K40m
Cuda compilation tools, release 8.0, V8.0.61
cudnn tried 5.0/6/7

Hi @zyq001,
You have to use tensorflow version 0.12.1.