Segmentation models with pretrained backbones. Keras and TensorFlow Keras.
MIT License
4.76k
stars
1.03k
forks
source link
ValueError: The `weights` argument should be either `None` (random initialization), `imagenet` (pre-training on ImageNet), or the path to the weights file to be loaded. #371
# define network parameters
n_classes = 1 if len(SEGMENTATION_CLASSES) == 1 else (len(SEGMENTATION_CLASSES) + 1) # case for binary and multiclass segmentation
activation = 'sigmoid' if n_classes == 1 else 'softmax'
#create model
model = sm.Unet(BACKBONE, classes=n_classes, activation=activation, encoder_weights='None',input_shape = (None, None, 3))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-31-a0481d301d20> in <module>()
4
5 #create model
----> 6 model = sm.Unet(BACKBONE, classes=n_classes, activation=activation, encoder_weights='None',input_shape = (None, None, 3))
5 frames
/usr/local/lib/python3.6/dist-packages/keras_applications/densenet.py in DenseNet(blocks, include_top, weights, input_tensor, input_shape, pooling, classes, **kwargs)
178
179 if not (weights in {'imagenet', None} or os.path.exists(weights)):
--> 180 raise ValueError('The `weights` argument should be either '
181 '`None` (random initialization), `imagenet` '
182 '(pre-training on ImageNet), '
ValueError: The `weights` argument should be either `None` (random initialization), `imagenet` (pre-training on ImageNet), or the path to the weights file to be loaded.
Using 'None' as input for sm.Unet doesn't work: