iamaaditya / VQA_Demo

Visual Question Answering Demo on pretrained model
http://iamaaditya.github.io/2016/04/visual_question_answering_demo_notebook
MIT License
241 stars 133 forks source link

Filter must not be larger than the input #9

Closed alibugra closed 7 years ago

alibugra commented 7 years ago

When I run demo.py file in order to test it, I see the following errors.

$ python demo.py -image_file_name test.jpg -question "Is there a man in the picture?"

Using TensorFlow backend.

Loading image features ...
Traceback (most recent call last):
  File "demo.py", line 114, in <module>
    main()
  File "demo.py", line 92, in main
    image_features = get_image_features(args.image_file_name, CNN_weights_file_name)
  File "demo.py", line 55, in get_image_features
    image_features[0,:] = get_image_model(CNN_weights_file_name).predict(im)[0]
  File "demo.py", line 20, in get_image_model
    image_model = VGG_16(CNN_weights_file_name)
  File "/home/alibugra/Desktop/VQA_Demo/models/CNN/VGG.py", line 39, in VGG_16
    model.add(MaxPooling2D((2,2), strides=(2,2)))
  File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 324, in add
    output_tensor = layer(self.outputs[0])
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 517, in __call__
    self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 571, in add_inbound_node
    Node.create_node(self, inbound_layers, node_indices, tensor_indices)
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 155, in create_node
    output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
  File "/usr/local/lib/python2.7/dist-packages/keras/layers/pooling.py", line 158, in call
    dim_ordering=self.dim_ordering)
  File "/usr/local/lib/python2.7/dist-packages/keras/layers/pooling.py", line 207, in _pooling_function
    border_mode, dim_ordering, pool_mode='max')
  File "/usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py", line 1815, in pool2d
    x = tf.nn.max_pool(x, pool_size, strides, padding=padding)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 665, in max_pool
    name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_nn_ops.py", line 1123, in _max_pool
    data_format=data_format, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 703, in apply_op
    op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2319, in create_op
    set_shapes_for_outputs(ret)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1711, in set_shapes_for_outputs
    shapes = shape_func(op)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/common_shapes.py", line 505, in max_pool_shape
    padding)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/common_shapes.py", line 184, in get2d_conv_output_size
    (row_stride, col_stride), padding_type)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/common_shapes.py", line 149, in get_conv_output_size
    "Filter: %r Input: %r" % (filter_size, input_size))
ValueError: Filter must not be larger than the input: Filter: (2, 2) Input: (1, 112)
iamaaditya commented 7 years ago

The command works for me with Tensorflow v0.11.

check the size of the image test.jpg

iamaaditya commented 7 years ago

9 Closing, no response.