Hi, nice work....
but i have errror in notebook ssd
please help ;)
Exception: Error when checking : expected input_2 to have shape (None, 300, 300, 3) but got array with shape (5, 3, 300, 300)
python 2.7 anaconda
keras and theano,tf updated to last
in python 3 warning
/home/rustam/anaconda2/envs/py3k/lib/python3.5/site-packages/keras/backend/theano_backend.py:1314: UserWarning: dict_keys(['filter_dilation']) are now deprecated in `tensor.nnet.abstract_conv.conv2d` interface and will be ignored.
filter_dilation=filter_dilation)
@fortunto2 I think the example is using tensorflow. In tensorflow, image converted to array has a different sequence from the one in theano. You can try to use tensorflow backend.
Alternatively, you can try to pass (3, 300, 300) as input_shape to SSD while constructing the net. However, Theano
backend was not tested (though I tried to support it for forward pass) and, moreover, the weights are also in Tensorflow
format, so, using Theano
without weights' conversion will be quite slow. What is more important, the loss function is implemented only in Tensorflow
, so, I agree with @MrXu and also suggest you to switch backend.
ok thanks, not principal...
but in tensorflow i catch new error))
ValueError Traceback (most recent call last)
<ipython-input-3-ea636890c378> in <module>()
1 input_shape=(300, 300, 3)
----> 2 model = SSD(input_shape, num_classes=NUM_CLASSES)
3 model.load_weights('weights_300x300.hdf5', by_name=True)
4 bbox_util = BBoxUtility(NUM_CLASSES)
/opt/neural/ssd_keras/ssd.pyc in SSD(input_shape, num_classes)
40 activation='relu',
41 border_mode='same',
---> 42 name='conv2_1')(net['pool1'])
43 net['conv2_2'] = Convolution2D(128, 3, 3,
44 activation='relu',
/home/rustam/anaconda2/lib/python2.7/site-packages/keras/engine/topology.pyc in __call__(self, x, mask)
514 if inbound_layers:
515 # This will call layer.build() if necessary.
--> 516 self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
517 # Outputs were already computed when calling self.add_inbound_node.
518 outputs = self.inbound_nodes[-1].output_tensors
/home/rustam/anaconda2/lib/python2.7/site-packages/keras/engine/topology.pyc in add_inbound_node(self, inbound_layers, node_indices, tensor_indices)
568 # creating the node automatically updates self.inbound_nodes
569 # as well as outbound_nodes on inbound layers.
--> 570 Node.create_node(self, inbound_layers, node_indices, tensor_indices)
571
572 def get_output_shape_for(self, input_shape):
/home/rustam/anaconda2/lib/python2.7/site-packages/keras/engine/topology.pyc in create_node(cls, outbound_layer, inbound_layers, node_indices, tensor_indices)
152
153 if len(input_tensors) == 1:
--> 154 output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
155 output_masks = to_list(outbound_layer.compute_mask(input_tensors[0], input_masks[0]))
156 # TODO: try to auto-infer shape if exception is raised by get_output_shape_for.
/home/rustam/anaconda2/lib/python2.7/site-packages/keras/layers/convolutional.pyc in call(self, x, mask)
464 border_mode=self.border_mode,
465 dim_ordering=self.dim_ordering,
--> 466 filter_shape=self.W_shape)
467 if self.bias:
468 if self.dim_ordering == 'th':
/home/rustam/anaconda2/lib/python2.7/site-packages/keras/backend/tensorflow_backend.pyc in conv2d(x, kernel, strides, border_mode, dim_ordering, image_shape, filter_shape, filter_dilation)
1675 if filter_dilation == (1, 1):
1676 strides = (1,) + strides + (1,)
-> 1677 x = tf.nn.conv2d(x, kernel, strides, padding=padding)
1678 else:
1679 assert filter_dilation[0] == filter_dilation[1]
/home/rustam/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/gen_nn_ops.pyc in conv2d(input, filter, strides, padding, use_cudnn_on_gpu, data_format, name)
392 strides=strides, padding=padding,
393 use_cudnn_on_gpu=use_cudnn_on_gpu,
--> 394 data_format=data_format, name=name)
395 return result
396
/home/rustam/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.pyc in apply_op(self, op_type_name, name, **keywords)
701 op = g.create_op(op_type_name, inputs, output_types, name=scope,
702 input_types=input_types, attrs=attr_protos,
--> 703 op_def=op_def)
704 outputs = op.outputs
705 return _Restructure(ops.convert_n_to_tensor(outputs),
/home/rustam/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.pyc in create_op(self, op_type, inputs, dtypes, input_types, name, attrs, op_def, compute_shapes, compute_device)
2310 original_op=self._default_original_op, op_def=op_def)
2311 if compute_shapes:
-> 2312 set_shapes_for_outputs(ret)
2313 self._add_op(ret)
2314 self._record_op_seen_by_control_dependencies(ret)
/home/rustam/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.pyc in set_shapes_for_outputs(op)
1702 raise RuntimeError("No shape function registered for standard op: %s"
1703 % op.type)
-> 1704 shapes = shape_func(op)
1705 if shapes is None:
1706 raise RuntimeError(
/home/rustam/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.pyc in conv2d_shape(op)
244 out_rows, out_cols = get2d_conv_output_size(in_rows, in_cols, filter_rows,
245 filter_cols, stride_r, stride_c,
--> 246 padding)
247
248 output_shape = [batch_size, out_rows, out_cols, depth_out]
/home/rustam/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.pyc in get2d_conv_output_size(input_height, input_width, filter_height, filter_width, row_stride, col_stride, padding_type)
182 return get_conv_output_size((input_height, input_width),
183 (filter_height, filter_width),
--> 184 (row_stride, col_stride), padding_type)
185
186
/home/rustam/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.pyc in get_conv_output_size(input_size, filter_size, strides, padding_type)
147 zip(filter_size, input_size)):
148 raise ValueError("Filter must not be larger than the input: "
--> 149 "Filter: %r Input: %r" % (filter_size, input_size))
150
151 if padding_type == b"VALID":
ValueError: Filter must not be larger than the input: Filter: (3, 3) Input: (150, 2)
Wow, this error looks really super strange. Are you sure, that you haven't change something in SSD
function accidentally?
Also, as I see, the error refers to _/opt/neural/ssd_keras/ssd.pyc,_ I am afraid, that .pyc
file could be obsolete and can have some Theano
backend footprints. Try do delete ssd.pyc
(NOT ssd.py
) and, please, comment, if it helps.
no... not helped delete all .pyc
@fortunto2 in your ~/.keras/keras.json
do you have both "image_dim_ordering": "tf"
and "backend": "tensorflow"
like in Keras docs?
my keras 1.1.1 py27_0, tensorflow 0.10.0rc0 np111py27_0
yes! thanks... not switch image_dim_ordering
Hooray! We've done it =)
all works! closed
thanks
Most helpful comment
@fortunto2 I think the example is using tensorflow. In tensorflow, image converted to array has a different sequence from the one in theano. You can try to use tensorflow backend.