MrGiovanni / UNetPlusPlus

[IEEE TMI] Official Implementation for UNet++
Other
2.31k stars 541 forks source link

How to input 6 depth data into xnet? #11

Open universewill opened 5 years ago

universewill commented 5 years ago

I set the model parameters as below:

model = Xnet(backbone_name='resnet152', input_shape=(None, None, 6), encoder_weights='imagenet11k', decoder_block_type='transpose')

And the error:

/device:GPU:0 with 10407 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)
image pairs number: 18
/home/universe/miniconda3/lib/python3.6/site-packages/keras_applications/imagenet_utils.py:279: UserWarning: This model usually expects 1 or 3 input channels. However, it was passed an input_shape with 6 input channels.
  str(input_shape[-1]) + ' input channels.')
Traceback (most recent call last):
  File "/home/universe/miniconda3/lib/python3.6/site-packages/tensorflow/python/framework/common_shapes.py", line 686, in _call_cpp_shape_fn_impl
    input_tensors_as_shapes, status)
  File "/home/universe/miniconda3/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 516, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimension 0 in both shapes must be equal, but are 6 and 3. Shapes are [6] and [3]. for 'Assign' (op: 'Assign') with input shapes: [6], [3].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "train_clothe.py", line 22, in <module>
    model = Xnet(backbone_name='resnet152', input_shape=(None, None, 6), encoder_weights='imagenet11k', decoder_block_type='transpose') # build UNet++
  File "/home/universe/jupyter/gxl/project/house_wall/models/Nested-UNet/segmentation_models/xnet/model.py", line 86, in Xnet
    include_top=False)
  File "/home/universe/jupyter/gxl/project/house_wall/models/Nested-UNet/segmentation_models/backbones/backbones.py", line 32, in get_backbone
    return backbones[name](*args, **kwargs)
  File "/home/universe/jupyter/gxl/project/house_wall/models/Nested-UNet/segmentation_models/backbones/classification_models/classification_models/resnet/models.py", line 69, in ResNet152
    load_model_weights(weights_collection, model, weights, classes, include_top)
  File "/home/universe/jupyter/gxl/project/house_wall/models/Nested-UNet/segmentation_models/backbones/classification_models/classification_models/utils.py", line 26, in load_model_weights
    model.load_weights(weights_path)
  File "/home/universe/miniconda3/lib/python3.6/site-packages/keras/engine/network.py", line 1166, in load_weights
    f, self.layers, reshape=reshape)
  File "/home/universe/miniconda3/lib/python3.6/site-packages/keras/engine/saving.py", line 1058, in load_weights_from_hdf5_group
    K.batch_set_value(weight_value_tuples)
  File "/home/universe/miniconda3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2465, in batch_set_value
    assign_op = x.assign(assign_placeholder)
  File "/home/universe/miniconda3/lib/python3.6/site-packages/tensorflow/python/ops/variables.py", line 609, in assign
    return state_ops.assign(self._variable, value, use_locking=use_locking)
  File "/home/universe/miniconda3/lib/python3.6/site-packages/tensorflow/python/ops/state_ops.py", line 281, in assign
    validate_shape=validate_shape)
  File "/home/universe/miniconda3/lib/python3.6/site-packages/tensorflow/python/ops/gen_state_ops.py", line 61, in assign
    use_locking=use_locking, name=name)
  File "/home/universe/miniconda3/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/home/universe/miniconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3292, in create_op
    compute_device=compute_device)
  File "/home/universe/miniconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3332, in _create_op_helper
    set_shapes_for_outputs(op)
  File "/home/universe/miniconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2496, in set_shapes_for_outputs
    return _set_shapes_for_outputs(op)
  File "/home/universe/miniconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2469, in _set_shapes_for_outputs
    shapes = shape_func(op)
  File "/home/universe/miniconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2399, in call_with_requiring
    return call_cpp_shape_fn(op, require_shape_fn=True)
  File "/home/universe/miniconda3/lib/python3.6/site-packages/tensorflow/python/framework/common_shapes.py", line 627, in call_cpp_shape_fn
    require_shape_fn)
  File "/home/universe/miniconda3/lib/python3.6/site-packages/tensorflow/python/framework/common_shapes.py", line 691, in _call_cpp_shape_fn_impl
    raise ValueError(err.message)
ValueError: Dimension 0 in both shapes must be equal, but are 6 and 3. Shapes are [6] and [3]. for 'Assign' (op: 'Assign') with input shapes: [6], [3].
twentyfiveYang commented 5 years ago

Hi @universewill ,I have the same problem as yours. Have you find the solution?

ShreyaPandita01 commented 4 years ago

Did anyone find a solution to this?