balancap / SDC-Vehicle-Detection

Udacity Project - Vehicle Detection
226 stars 113 forks source link

TypeError: __init__() got multiple values for keyword argument 'dtype' #2

Open mysope opened 7 years ago

mysope commented 7 years ago

SSD network construction.

reuse = True if 'ssd' in locals() else None ssd = ssd_vgg_300.SSDNet(params) with slim.arg_scope(ssd.arg_scope(weight_decay=0.0005)): predictions, localisations, logits, end_points = ssd.net(image_4d, is_training=False, reuse=reuse)


When running the above command line on the ipython notebook, the following error occurs. What should I fix?


TypeError Traceback (most recent call last)

in () 13 ssd = ssd_vgg_300.SSDNet(params) 14 with slim.arg_scope(ssd.arg_scope(weight_decay=0.0005)): ---> 15 predictions, localisations, logits, end_points = ssd.net(image_4d, is_training=False, reuse=reuse) /home/nwkim/TF-Sample/SDC-Vehicle-Detection/nets/ssd_vgg_300.py in net(self, inputs, is_training, update_feat_shapes, dropout_keep_prob, prediction_fn, reuse, scope) 126 prediction_fn=prediction_fn, 127 reuse=reuse, --> 128 scope=scope) 129 # Update feature shapes (try at least!) 130 if update_feat_shapes: /home/nwkim/TF-Sample/SDC-Vehicle-Detection/nets/ssd_vgg_300.py in ssd_net(inputs, num_classes, feat_layers, anchor_sizes, anchor_ratios, normalizations, is_training, dropout_keep_prob, prediction_fn, reuse, scope) 392 with tf.variable_scope(scope, 'ssd_300_vgg', [inputs], reuse=reuse): 393 # Original VGG-16 blocks. --> 394 net = slim.repeat(inputs, 2, slim.conv2d, 64, [3, 3], scope='conv1') 395 end_points['block1'] = net 396 net = slim.max_pool2d(net, [2, 2], scope='pool1') /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/layers/layers.pyc in repeat(inputs, repetitions, layer, *args, **kwargs) 1718 for i in range(repetitions): 1719 kwargs['scope'] = scope + '_' + str(i+1) -> 1720 outputs = layer(outputs, *args, **kwargs) 1721 return outputs 1722 /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.pyc in func_with_args(*args, **kwargs) 175 current_args = current_scope[key_func].copy() 176 current_args.update(kwargs) --> 177 return func(*args, **current_args) 178 _add_op(func) 179 setattr(func_with_args, '_key_op', _key_op(func)) /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/layers/layers.pyc in convolution(inputs, num_outputs, kernel_size, stride, padding, data_format, rate, activation_fn, normalizer_fn, normalizer_params, weights_initializer, weights_regularizer, biases_initializer, biases_regularizer, reuse, variables_collections, outputs_collections, trainable, scope) 905 _scope=sc, 906 _reuse=reuse) --> 907 outputs = layer.apply(inputs) 908 909 # Add variables to collections. /usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.pyc in apply(self, inputs, **kwargs) 301 Output tensor(s). 302 """ --> 303 return self.__call__(inputs, **kwargs) 304 305 /usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.pyc in __call__(self, inputs, **kwargs) 267 input_shapes = [x.get_shape() for x in input_list] 268 if len(input_shapes) == 1: --> 269 self.build(input_shapes[0]) 270 else: 271 self.build(input_shapes) /usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/convolutional.pyc in build(self, input_shape) 143 regularizer=self.bias_regularizer, 144 trainable=True, --> 145 dtype=self.dtype) 146 else: 147 self.bias = None /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.pyc in get_variable(name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, partitioner, validate_shape, custom_getter) 986 collections=collections, caching_device=caching_device, 987 partitioner=partitioner, validate_shape=validate_shape, --> 988 custom_getter=custom_getter) 989 get_variable_or_local_docstring = ( 990 """%s /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.pyc in get_variable(self, var_store, name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, partitioner, validate_shape, custom_getter) 888 collections=collections, caching_device=caching_device, 889 partitioner=partitioner, validate_shape=validate_shape, --> 890 custom_getter=custom_getter) 891 892 def _get_partitioned_variable(self, /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.pyc in get_variable(self, name, shape, dtype, initializer, regularizer, reuse, trainable, collections, caching_device, partitioner, validate_shape, custom_getter) 339 reuse=reuse, trainable=trainable, collections=collections, 340 caching_device=caching_device, partitioner=partitioner, --> 341 validate_shape=validate_shape) 342 else: 343 return _true_getter( /usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.pyc in variable_getter(getter, name, shape, dtype, initializer, regularizer, trainable, **kwargs) 256 name, shape, initializer=initializer, regularizer=regularizer, 257 dtype=dtype, trainable=trainable, --> 258 variable_getter=functools.partial(getter, **kwargs)) 259 260 # Build (if necessary) and call the layer, inside a variable scope. /usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.pyc in _add_variable(self, name, shape, dtype, initializer, regularizer, trainable, variable_getter) 206 initializer=initializer, 207 dtype=dtype, --> 208 trainable=trainable and self.trainable) 209 # TODO(sguada) fix name = variable.op.name 210 if variable in existing_variables: /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/layers/layers.pyc in layer_variable_getter(getter, *args, **kwargs) 1308 getter = functools.partial(current_custom_getter, getter) 1309 kwargs['rename'] = rename -> 1310 return _model_variable_getter(getter, *args, **kwargs) 1311 return layer_variable_getter 1312 /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/layers/layers.pyc in _model_variable_getter(getter, name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, partitioner, rename, **_) 1297 regularizer=regularizer, collections=collections, trainable=trainable, 1298 caching_device=caching_device, partitioner=partitioner, -> 1299 custom_getter=getter) 1300 1301 /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.pyc in func_with_args(*args, **kwargs) 175 current_args = current_scope[key_func].copy() 176 current_args.update(kwargs) --> 177 return func(*args, **current_args) 178 _add_op(func) 179 setattr(func_with_args, '_key_op', _key_op(func)) /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/variables.pyc in model_variable(name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, device, partitioner, custom_getter) 266 trainable=trainable, collections=collections, 267 caching_device=caching_device, device=device, --> 268 partitioner=partitioner, custom_getter=custom_getter) 269 return var 270 /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.pyc in func_with_args(*args, **kwargs) 175 current_args = current_scope[key_func].copy() 176 current_args.update(kwargs) --> 177 return func(*args, **current_args) 178 _add_op(func) 179 setattr(func_with_args, '_key_op', _key_op(func)) /usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/variables.pyc in variable(name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, device, partitioner, custom_getter) 223 collections=collections, 224 caching_device=caching_device, --> 225 partitioner=partitioner) 226 227 /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.pyc in _true_getter(name, shape, dtype, initializer, regularizer, reuse, trainable, collections, caching_device, partitioner, validate_shape) 331 initializer=initializer, regularizer=regularizer, reuse=reuse, 332 trainable=trainable, collections=collections, --> 333 caching_device=caching_device, validate_shape=validate_shape) 334 335 if custom_getter is not None: /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.pyc in _get_single_variable(self, name, shape, dtype, initializer, regularizer, partition_info, reuse, trainable, collections, caching_device, validate_shape) 682 caching_device=caching_device, 683 dtype=variable_dtype, --> 684 validate_shape=validate_shape) 685 self._vars[name] = v 686 logging.vlog(1, "Created variable %s with shape %s and init %s", v.name, /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variables.pyc in __init__(self, initial_value, trainable, collections, validate_shape, caching_device, name, variable_def, dtype, expected_shape, import_scope) 195 name=name, 196 dtype=dtype, --> 197 expected_shape=expected_shape) 198 199 def __str__(self): /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variables.pyc in _init_from_args(self, initial_value, trainable, collections, validate_shape, caching_device, name, dtype, expected_shape) 272 with ops.name_scope("Initializer"), ops.device(None): 273 self._initial_value = ops.convert_to_tensor( --> 274 initial_value(), name="initial_value", dtype=dtype) 275 shape = (self._initial_value.get_shape() 276 if validate_shape else tensor_shape.unknown_shape()) /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.pyc in () 671 else: 672 init_val = lambda: initializer( --> 673 shape.as_list(), dtype=dtype, partition_info=partition_info) 674 variable_dtype = dtype.base_dtype 675 TypeError: __init__() got multiple values for keyword argument 'dtype'
villanuevab commented 7 years ago

This issue is related to https://github.com/tensorflow/tensorflow/issues/7496 . This may fix your errors.

If other errors occur, note that the author @balancap has updated SSD-Tensorflow but not yet pushed changes to this repo. I was experiencing similar errors and updated my SDC-Vehicle-Detection repo by replacing folders nets/ and preprocessing/ with the corresponding versions from SSD-Tensorflow, and adding the directory tf_extended/ to my repo as well. Depending on your use case, you may need to copy a few more files over.

cocoza4 commented 7 years ago

Hi @villanuevab, did you have to modify some code after replacing nets/, preprocessing/ from SSD-Tensorflow repo?

In vehicle-detection.ipynb for example, there are methods that do not exist in the SSD-Tensorflow nets/ such as ssd_common.ssd_bboxes_select. I found that it's equivalent to ssd_common.tf_ssd_bboxes_select but the parameters returned are different.

thanks Peeranat F.

villanuevab commented 7 years ago

Hello. Thank you for your question! Actually, although I got SSD-Tensorflow to run, I was never able to get good results. Training using this repo (unchanged), SDC-Vehicle-Detection, was more fruitful. I have not kept up to date with this repo or SSD-Tensorflow, but the latest models that actually achieved reasonable results came from using SDC-Vehicle-Detection.

cocoza4 commented 7 years ago

Thanks for your response. So how did you manage to get SDC-Vehicle-Detection to work and get reasonable results and solve "TypeError: init() got multiple values for keyword argument 'dtype'" then?

If you don't mind me asking what model(s) you use that got you the best result for self driving car vehicle detection? My team might try that out. Right now we are focusing on only SSD and Udacity's dataset.

thanks