ManishSoni1908 / Mobilenet-ssd-keras

A Keras port of Single Shot MultiBox Detector as Mobilenet as a Backbone
62 stars 24 forks source link

Error on load_model #5

Open cuongnm71 opened 4 years ago

cuongnm71 commented 4 years ago

i save model using:

model.save('mobilenet-ssd_model.h5')

but it got error:

TypeError                                 Traceback (most recent call last)
<ipython-input-11-b8bfa7c7a7ed> in <module>()
----> 1 model = load_model('mobilenet-ssd_model.h5')
11 frames
/usr/local/lib/python3.6/dist-packages/keras/engine/saving.py in load_wrapper(*args, **kwargs)
    456                 os.remove(tmp_filepath)
    457             return res
--> 458         return load_function(*args, **kwargs)
    459 
    460     return load_wrapper

/usr/local/lib/python3.6/dist-packages/keras/engine/saving.py in load_model(filepath, custom_objects, compile)
    548     if H5Dict.is_supported_type(filepath):
    549         with H5Dict(filepath, mode='r') as h5dict:
--> 550             model = _deserialize_model(h5dict, custom_objects, compile)
    551     elif hasattr(filepath, 'write') and callable(filepath.write):
    552         def load_function(h5file):

/usr/local/lib/python3.6/dist-packages/keras/engine/saving.py in _deserialize_model(h5dict, custom_objects, compile)
    241         raise ValueError('No model found in config.')
    242     model_config = json.loads(model_config.decode('utf-8'))
--> 243     model = model_from_config(model_config, custom_objects=custom_objects)
    244     model_weights_group = h5dict['model_weights']
    245 

/usr/local/lib/python3.6/dist-packages/keras/engine/saving.py in model_from_config(config, custom_objects)
    591                         '`Sequential.from_config(config)`?')
    592     from ..layers import deserialize
--> 593     return deserialize(config, custom_objects=custom_objects)
    594 
    595 

/usr/local/lib/python3.6/dist-packages/keras/layers/__init__.py in deserialize(config, custom_objects)
    166                                     module_objects=globs,
    167                                     custom_objects=custom_objects,
--> 168                                     printable_module_name='layer')

/usr/local/lib/python3.6/dist-packages/keras/utils/generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)
    145                     config['config'],
    146                     custom_objects=dict(list(_GLOBAL_CUSTOM_OBJECTS.items()) +
--> 147                                         list(custom_objects.items())))
    148             with CustomObjectScope(custom_objects):
    149                 return cls.from_config(config['config'])

/usr/local/lib/python3.6/dist-packages/keras/engine/network.py in from_config(cls, config, custom_objects)
   1041         # First, we create all layers and enqueue nodes to be processed
   1042         for layer_data in config['layers']:
-> 1043             process_layer(layer_data)
   1044 
   1045         # Then we process nodes in order of layer depth.

/usr/local/lib/python3.6/dist-packages/keras/engine/network.py in process_layer(layer_data)
   1027 
   1028             layer = deserialize_layer(layer_data,
-> 1029                                       custom_objects=custom_objects)
   1030             created_layers[layer_name] = layer
   1031 

/usr/local/lib/python3.6/dist-packages/keras/layers/__init__.py in deserialize(config, custom_objects)
    166                                     module_objects=globs,
    167                                     custom_objects=custom_objects,
--> 168                                     printable_module_name='layer')

/usr/local/lib/python3.6/dist-packages/keras/utils/generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)
    147                                         list(custom_objects.items())))
    148             with CustomObjectScope(custom_objects):
--> 149                 return cls.from_config(config['config'])
    150         else:
    151             # Then `cls` may be a function returning a class.

/usr/local/lib/python3.6/dist-packages/keras/engine/base_layer.py in from_config(cls, config)
   1101             A layer instance.
   1102         """
-> 1103         return cls(**config)
   1104 
   1105     def count_params(self):

/usr/local/lib/python3.6/dist-packages/keras/layers/convolutional.py in __init__(self, kernel_size, strides, padding, depth_multiplier, data_format, dilation_rate, activation, use_bias, depthwise_initializer, bias_initializer, depthwise_regularizer, bias_regularizer, activity_regularizer, depthwise_constraint, bias_constraint, **kwargs)
   1797             activity_regularizer=activity_regularizer,
   1798             bias_constraint=bias_constraint,
-> 1799             **kwargs)
   1800         self.depth_multiplier = depth_multiplier
   1801         self.depthwise_initializer = initializers.get(depthwise_initializer)

TypeError: __init__() got multiple values for keyword argument 'filters'
vkherde commented 4 years ago

Hi @nmc1998 I am having same issue on using load_model ,Can you please help in sorting out this issue?