[Python] Unrecognized keyword arguments passed to DepthwiseConv2D: {'groups': 1} error when...

Discussão em 'Python' iniciado por Stack, Novembro 27, 2024.

  1. Stack

    Stack Membro Participativo

    I'm trying to load this face anit-spoofing model. It is a MobileNetV2 model. I want to convert it to coreML format. I have uploaded the .h5 model file into the colab. But when I try to load the model using tensorflow I get this following error.


    ValueError: Unrecognized keyword arguments passed to DepthwiseConv2D: {'groups': 1}

    During handling of the above exception, another exception occurred:


    Here is my python code to load the model and print the model summary. The tensor flow version in Colab 2.17 I have downgraded it to 2.16 because I found this API documentation for DepthWiseConv2D for tensorflow version 2.16. But still the same error occurs. Here is my code

    import tensorflow as tf
    import coremltools as ct


    model = tf.keras.models.load_model('/content/MobileNetV2.h5')
    print(model.summary())


    When I run the code it gives me this error


    ValueError Traceback (most recent call last)
    /usr/local/lib/python3.10/dist-packages/keras/src/ops/operation.py in from_config(cls, config)
    233 try:
    --> 234 return cls(**config)
    235 except Exception as e:

    16 frames
    ValueError: Unrecognized keyword arguments passed to DepthwiseConv2D: {'groups': 1}

    During handling of the above exception, another exception occurred:

    TypeError Traceback (most recent call last)
    /usr/local/lib/python3.10/dist-packages/keras/src/ops/operation.py in from_config(cls, config)
    234 return cls(**config)
    235 except Exception as e:
    --> 236 raise TypeError(
    237 f"Error when deserializing class '{cls.__name__}' using "
    238 f"config={config}.\n\nException encountered: {e}"

    TypeError: Error when deserializing class 'DepthwiseConv2D' using config={'name': 'expanded_conv_depthwise', 'trainable': True, 'dtype': 'float32', 'kernel_size': [3, 3], 'strides': [1, 1], 'padding': 'same', 'data_format': 'channels_last', 'dilation_rate': [1, 1], 'groups': 1, 'activation': 'linear', 'use_bias': False, 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, 'bias_regularizer': None, 'activity_regularizer': None, 'bias_constraint': None, 'depth_multiplier': 1, 'depthwise_initializer': {'class_name': 'GlorotUniform', 'config': {'seed': None}}, 'depthwise_regularizer': None, 'depthwise_constraint': None}.

    Continue reading...

Compartilhe esta Página