Golbstein / Keras-segmentation-deeplab-v3.1

An awesome semantic segmentation model that runs in real time
175 stars 72 forks source link

when change 'better_model' as True encountered ValueError #2

Closed puphy closed 5 years ago

puphy commented 5 years ago

when I set better_model = True and run create_seg_model, I encountered error as follow: `InvalidArgumentError Traceback (most recent call last) ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in _create_c_op(graph, node_def, inputs, control_inputs) 1575 try: -> 1576 c_op = c_api.TF_FinishOperation(op_desc) 1577 except errors.InvalidArgumentError as e:

InvalidArgumentError: Dimension 0 in both shapes must be equal, but are 1 and 1344. Shapes are [1,1,256,21] and [1344,256,1,1]. for 'Assign_813' (op: 'Assign') with input shapes: [1,1,256,21], [1344,256,1,1].

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last)

in () 1 if better_model: ----> 2 model = SegClass.create_seg_model(net='subpixel',n=n_classes, load_weights=True, multi_gpu=False, backbone=backbone) 3 else: 4 model = SegClass.create_seg_model(net='original',n=n_classes, load_weights=True, multi_gpu=False, backbone=backbone) 5 ~/project/Keras-segmentation-deeplab-v3.1/utils.py in create_seg_model(self, net, n, backbone, load_weights, multi_gpu) 157 backbone=backbone, OS=8, alpha=1) 158 if load_weights: --> 159 model.load_weights('weights/{}_{}.h5'.format(backbone, net)) 160 161 base_model = Model(model.input, model.layers[-5].output) ~/anaconda3/lib/python3.6/site-packages/keras/engine/network.py in load_weights(self, filepath, by_name, skip_mismatch, reshape) 1159 else: 1160 saving.load_weights_from_hdf5_group( -> 1161 f, self.layers, reshape=reshape) 1162 1163 def _updated_config(self): ~/anaconda3/lib/python3.6/site-packages/keras/engine/saving.py in load_weights_from_hdf5_group(f, layers, reshape) 926 ' elements.') 927 weight_value_tuples += zip(symbolic_weights, weight_values) --> 928 K.batch_set_value(weight_value_tuples) 929 930 ~/anaconda3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py in batch_set_value(tuples) 2433 assign_placeholder = tf.placeholder(tf_dtype, 2434 shape=value.shape) -> 2435 assign_op = x.assign(assign_placeholder) 2436 x._assign_placeholder = assign_placeholder 2437 x._assign_op = assign_op ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/variables.py in assign(self, value, use_locking) 643 the assignment has completed. 644 """ --> 645 return state_ops.assign(self._variable, value, use_locking=use_locking) 646 647 def assign_add(self, delta, use_locking=False): ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/state_ops.py in assign(ref, value, validate_shape, use_locking, name) 214 return gen_state_ops.assign( 215 ref, value, use_locking=use_locking, name=name, --> 216 validate_shape=validate_shape) 217 return ref.assign(value, name=name) 218 ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gen_state_ops.py in assign(ref, value, validate_shape, use_locking, name) 58 _, _, _op = _op_def_lib._apply_op_helper( 59 "Assign", ref=ref, value=value, validate_shape=validate_shape, ---> 60 use_locking=use_locking, name=name) 61 _result = _op.outputs[:] 62 _inputs_flat = _op.inputs ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py in _apply_op_helper(self, op_type_name, name, **keywords) 785 op = g.create_op(op_type_name, inputs, output_types, name=scope, 786 input_types=input_types, attrs=attr_protos, --> 787 op_def=op_def) 788 return output_structure, op_def.is_stateful, op 789 ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py in new_func(*args, **kwargs) 452 'in a future version' if date is None else ('after %s' % date), 453 instructions) --> 454 return func(*args, **kwargs) 455 return tf_decorator.make_decorator(func, new_func, 'deprecated', 456 _add_deprecated_arg_notice_to_docstring( ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in create_op(***failed resolving arguments***) 3153 input_types=input_types, 3154 original_op=self._default_original_op, -> 3155 op_def=op_def) 3156 self._create_op_helper(ret, compute_device=compute_device) 3157 return ret ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in __init__(self, node_def, g, inputs, output_types, control_inputs, input_types, original_op, op_def) 1729 op_def, inputs, node_def.attr) 1730 self._c_op = _create_c_op(self._graph, node_def, grouped_inputs, -> 1731 control_input_ops) 1732 1733 # Initialize self._outputs. ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in _create_c_op(graph, node_def, inputs, control_inputs) 1577 except errors.InvalidArgumentError as e: 1578 # Convert to ValueError for backwards compatibility. -> 1579 raise ValueError(str(e)) 1580 1581 return c_op ValueError: Dimension 0 in both shapes must be equal, but are 1 and 1344. Shapes are [1,1,256,21] and [1344,256,1,1]. for 'Assign_813' (op: 'Assign') with input shapes: [1,1,256,21], [1344,256,1,1]. ` could you help me with my problem? Thank you!
enavarroAI commented 5 years ago

Same here.

Golbstein commented 5 years ago

You're right. I fixed it. The problem occurred because I tried to load the subpixel model before I've added this layers.