kappazeta / km_predict

S2 full image prediction
Apache License 2.0
20 stars 9 forks source link

DeepLab: Mismatching Concatenate layer input shapes #20

Closed indrek-sunter closed 2 years ago

indrek-sunter commented 2 years ago

There seems to be an issue with the DeepLab architecture, which seems to be the recommended architecture, at least judging by config/config_example.json.

I'm running km-predict as follows: python km_predict.py -c config/config_test.json.

Configuration:

{
  "cm_vsm": {
    "path": "/home/kappazeta/Documents/projects/kappamask/cm-vsm/vsm/build/bin/cm_vsm",
    "env": {
      "LD_LIBRARY_PATH": "." 
    }   
  },  
  "folder_name": "data",
  "product_name": "S2B_MSIL1C_20211231T100319_N0301_R122_T34VEL_20211231T110228",
  "level_product": "L1C",
  "overlapping": 0.0625,
  "tile_size": 512,
  "resampling_method" : "sinc",
  "architecture": "DeepLab",
  "batch_size": 1
}

Error:

Traceback (most recent call last):
  File "/home/kappazeta/Documents/projects/kappamask/km_predict/km_predict.py", line 437, in <module>
    main()
  File "/home/kappazeta/Documents/projects/kappamask/km_predict/km_predict.py", line 433, in main
    kmf.predict(force_predict = args.force_predict)
  File "/home/kappazeta/Documents/projects/kappamask/km_predict/km_predict.py", line 227, in predict
    self.model.construct(self.tile_size, self.tile_size, len(self.features), len(self.classes))
  File "/home/kappazeta/Documents/projects/kappamask/km_predict/architectures.py", line 404, in construct
    x = tf.keras.layers.Concatenate(axis = -1)([input_a, input_b])
  File "/home/kappazeta/micromamba/envs/km_predict/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py", line 951, in __call__
    return self._functional_construction_call(inputs, args, kwargs,
  File "/home/kappazeta/micromamba/envs/km_predict/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1090, in _functional_construction_call
    outputs = self._keras_tensor_symbolic_call(
  File "/home/kappazeta/micromamba/envs/km_predict/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py", line 822, in _keras_tensor_symbolic_call
    return self._infer_output_signature(inputs, args, kwargs, input_masks)
  File "/home/kappazeta/micromamba/envs/km_predict/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py", line 862, in _infer_output_signature
    self._maybe_build(inputs)
  File "/home/kappazeta/micromamba/envs/km_predict/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py", line 2710, in _maybe_build
    self.build(input_shapes)  # pylint:disable=not-callable
  File "/home/kappazeta/micromamba/envs/km_predict/lib/python3.9/site-packages/tensorflow/python/keras/utils/tf_utils.py", line 272, in wrapper
    output_shape = fn(instance, input_shape)
  File "/home/kappazeta/micromamba/envs/km_predict/lib/python3.9/site-packages/tensorflow/python/keras/layers/merge.py", line 519, in build
    raise ValueError(err_msg)
ValueError: A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got inputs shapes: [(None, 128, 128, 256), (None, 127, 127, 48)]
indrek-sunter commented 2 years ago

It seems to be working fine with Unet or DeepLabv3Plus (with the latter being superior).

indrek-sunter commented 2 years ago

DeepLabv3Plus is only available for L1C but not yet for L2A. For L2A products, Unet should be the latest available model.