Fixing 'Incompatible Shapes' error
See original GitHub issueI am trying to train this model on my own data. I have been able to get it to work before with my own data, but I wanted to have my images semantically segmented beforehand, so I used a different model to do so, and I think in doing so I must have changed my environment enough to start getting this error because I highly doubt it’s an issue with the new images I’m using. They are the same size as the previous. I have run the requirements.txt file and still am getting this issue. I have posted the error below. Any help on what the problem might be and how to fix it would be greatly appreciated. Thank you in advance!
Starting training…
Train for 200 steps, validate for 1169 steps
Epoch 1/100
2020-12-06 20:35:50.965473: W tensorflow/core/common_runtime/base_collective_executor.cc:217] BaseCollectiveExecutor::StartAbort Invalid argument: Incompatible shapes: [3] vs. [256,512,4]
[[{{node Equal_29}}]]
[[IteratorGetNext]]
2020-12-06 20:35:50.987892: W tensorflow/core/common_runtime/base_collective_executor.cc:217] BaseCollectiveExecutor::StartAbort Invalid argument: Incompatible shapes: [3] vs. [256,512,4]
[[{{node Equal_29}}]]
[[IteratorGetNext]]
[[metrics/mean_io_u_with_one_hot_labels/StatefulPartitionedCall/confusion_matrix/assert_non_negative/assert_less_equal/Assert/AssertGuard/else/_6/Assert/data_1/_20]]
1/200 […] - ETA: 35:21WARNING:tensorflow:Can save best model only with val_mean_io_u_with_one_hot_labels available, skipping.
WARNING:tensorflow:Early stopping conditioned on metric val_mean_io_u_with_one_hot_labels
which is not available. Available metrics are:
Traceback (most recent call last):
File “./train.py”, line 185, in <module>
callbacks=callbacks)
File “/home/techlab_grizzly/Desktop/Cam2BEV/env37/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training.py”, line 819, in fit
use_multiprocessing=use_multiprocessing)
File “/home/techlab_grizzly/Desktop/Cam2BEV/env37/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training_v2.py”, line 342, in fit
total_epochs=epochs)
File “/home/techlab_grizzly/Desktop/Cam2BEV/env37/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training_v2.py”, line 128, in run_one_epoch
batch_outs = execution_function(iterator)
File “/home/techlab_grizzly/Desktop/Cam2BEV/env37/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training_v2_utils.py”, line 98, in execution_function
distributed_function(input_fn))
File “/home/techlab_grizzly/Desktop/Cam2BEV/env37/lib/python3.7/site-packages/tensorflow_core/python/eager/def_function.py”, line 568, in call
result = self._call(*args, **kwds)
File “/home/techlab_grizzly/Desktop/Cam2BEV/env37/lib/python3.7/site-packages/tensorflow_core/python/eager/def_function.py”, line 632, in _call
return self._stateless_fn(*args, **kwds)
File “/home/techlab_grizzly/Desktop/Cam2BEV/env37/lib/python3.7/site-packages/tensorflow_core/python/eager/function.py”, line 2363, in call
return graph_function._filtered_call(args, kwargs) # pylint: disable=protected-access
File “/home/techlab_grizzly/Desktop/Cam2BEV/env37/lib/python3.7/site-packages/tensorflow_core/python/eager/function.py”, line 1611, in _filtered_call
self.captured_inputs)
File “/home/techlab_grizzly/Desktop/Cam2BEV/env37/lib/python3.7/site-packages/tensorflow_core/python/eager/function.py”, line 1692, in _call_flat
ctx, args, cancellation_manager=cancellation_manager))
File “/home/techlab_grizzly/Desktop/Cam2BEV/env37/lib/python3.7/site-packages/tensorflow_core/python/eager/function.py”, line 545, in call
ctx=ctx)
File “/home/techlab_grizzly/Desktop/Cam2BEV/env37/lib/python3.7/site-packages/tensorflow_core/python/eager/execute.py”, line 67, in quick_execute
six.raise_from(core._status_to_exception(e.code, message), None)
File “<string>”, line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [3] vs. [256,512,4]
[[{{node Equal_29}}]]
[[IteratorGetNext]] [Op:__inference_distributed_function_17137]
Function call stack:
distributed_function
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6
I accidentally closed this issue so just commenting again to make sure you can see the last comment:
https://github.com/boycejam/Our_BEV_Files
Above is the link to a repo I made containing the files you mentioned. Let me know if there is anything else you need
Problem is that your input image has a fourth alpha channel, s.t. the resized image has shape
(256, 512, 4)
. This causes the crash during one-hot-encoding.I will push a fix tomorrow, s.t. an image will always be loaded as RGB instead of RGBA, even if present. In the meantime, you can fix it yourself by replacing utils.py#L77 with
Some more notes on your files:
0,0,142
(RGB) blue is listed in theconvert_10.xml
. You need to check the colors you specify there.(640, 480)
, while your input image has shape(480, 640)
. Keep in mind that both will be center-cropped/resized to(256, 512)
.