I'm getting some kind of error relating to BatchNormalization as soon as I try to instantiate a Unet model:
import segmentation_models as sm
# sm.set_framework('tf.keras')
# sm.framework()
# import keras
from tensorflow import keras
print('Setting image data format...')
# keras.backend.set_image_data_format('channels_last')
keras.backend.set_image_data_format('channels_first')
print('Retrieving preprocessing function...')
BACKBONE = 'resnet34'
preprocess_input = sm.get_preprocessing(BACKBONE)
print('Defining model...')
# define model
model = sm.Unet(BACKBONE, encoder_weights='imagenet')
Results in:
trainval_keras.py
2021-06-17 19:29:15.101726: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2021-06-17 19:29:15.101749: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Segmentation Models: using `tf.keras` framework.
Setting image data format...
Retrieving preprocessing function...
Defining model...
Traceback (most recent call last):
File "/home/sal9000/PycharmProjects/roi_segmentation/roi_segmentation/trainval_keras.py", line 19, in <module>
model = sm.Unet(BACKBONE, encoder_weights='imagenet')
File "/home/sal9000/virtualenvs/roisegenv/lib/python3.6/site-packages/segmentation_models/__init__.py", line 34, in wrapper
return func(*args, **kwargs)
File "/home/sal9000/virtualenvs/roisegenv/lib/python3.6/site-packages/segmentation_models/models/unet.py", line 226, in Unet
**kwargs,
File "/home/sal9000/virtualenvs/roisegenv/lib/python3.6/site-packages/segmentation_models/backbones/backbones_factory.py", line 103, in get_backbone
model = model_fn(*args, **kwargs)
File "/home/sal9000/virtualenvs/roisegenv/lib/python3.6/site-packages/classification_models/models_factory.py", line 78, in wrapper
return func(*args, **new_kwargs)
File "/home/sal9000/virtualenvs/roisegenv/lib/python3.6/site-packages/classification_models/models/resnet.py", line 321, in ResNet34
**kwargs
File "/home/sal9000/virtualenvs/roisegenv/lib/python3.6/site-packages/classification_models/models/resnet.py", line 231, in ResNet
x = layers.BatchNormalization(name='bn_data', **no_scale_bn_params)(img_input)
File "/home/sal9000/virtualenvs/roisegenv/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 970, in __call__
input_list)
File "/home/sal9000/virtualenvs/roisegenv/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1108, in _functional_construction_call
inputs, input_masks, args, kwargs)
File "/home/sal9000/virtualenvs/roisegenv/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 840, in _keras_tensor_symbolic_call
return self._infer_output_signature(inputs, args, kwargs, input_masks)
File "/home/sal9000/virtualenvs/roisegenv/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 878, in _infer_output_signature
self._maybe_build(inputs)
File "/home/sal9000/virtualenvs/roisegenv/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 2625, in _maybe_build
self.build(input_shapes) # pylint:disable=not-callable
File "/home/sal9000/virtualenvs/roisegenv/lib/python3.6/site-packages/tensorflow/python/keras/layers/normalization.py", line 387, in build
(tuple(input_shape), self.axis))
ValueError: Input has undefined `axis` dimension. Received input with shape (None, None, None, 3). Axis value: ListWrapper([1])
I'm getting some kind of error relating to BatchNormalization as soon as I try to instantiate a Unet model:
Results in:
Packages I have installed in this virtualenv:
Is it some issue of incompatable versions of TF/Keras/segmentation-models that I have?