Description
Cell In[10], line 1
----> 1 model = load_model(HOME + '/deepposekit-data/datasets/fly/best_model_densenet.h5')
File /opt/conda/lib/python3.10/site-packages/deepposekit/models/loading.py:79, in load_model(path, generator, augmenter, custom_objects, compile)
76 else:
77 raise TypeError("file must be type str
")
---> 79 train_model = save.load_model(filepath, custom_objects=custom_objects, compile=compile)
81 with h5py.File(filepath, "r") as h5file:
82 train_generator_config = h5file.attrs.get("train_generator_config")
File /opt/conda/lib/python3.10/site-packages/tensorflow/python/keras/saving/save.py:197, in load_model(filepath, custom_objects, compile, options)
194 with load_context.load_context(options):
195 if (h5py is not None and
196 (isinstance(filepath, h5py.File) or h5py.is_hdf5(filepath))):
--> 197 return hdf5_format.load_model_from_hdf5(filepath, custom_objects,
198 compile)
200 filepath = path_to_string(filepath)
201 if isinstance(filepath, str):
File /opt/conda/lib/python3.10/site-packages/tensorflow/python/keras/saving/hdf5_format.py:180, in load_model_from_hdf5(filepath, custom_objects, compile)
178 model_config = model_config.decode('utf-8')
179 model_config = json_utils.decode(model_config)
--> 180 model = model_config_lib.model_from_config(model_config,
181 custom_objects=custom_objects)
183 # set weights
184 load_weights_from_hdf5_group(f['model_weights'], model.layers)
File /opt/conda/lib/python3.10/site-packages/tensorflow/python/keras/saving/model_config.py:50, in model_from_config(config, custom_objects)
46 raise TypeError('model_from_config
expects a dictionary, not a list. '
47 'Maybe you meant to use '
48 'Sequential.from_config(config)
?')
49 from tensorflow.python.keras.layers import deserialize # pylint: disable=g-import-not-at-top
---> 50 return deserialize(config, custom_objects=custom_objects)
File /opt/conda/lib/python3.10/site-packages/tensorflow/python/keras/layers/serialization.py:113, in deserialize(config, custom_objects)
102 """Instantiates a layer from a config dictionary.
103
104 Args:
(...)
110 Layer instance (may be Model, Sequential, Network, Layer...)
111 """
112 populate_deserializable_objects()
--> 113 return generic_utils.deserialize_keras_object(
114 config,
115 module_objects=LOCAL.ALL_OBJECTS,
116 custom_objects=custom_objects,
117 printable_module_name='layer')
File /opt/conda/lib/python3.10/site-packages/tensorflow/python/keras/utils/generic_utils.py:665, in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)
662 custom_objects = custom_objects or {}
664 if 'custom_objects' in arg_spec.args:
--> 665 deserialized_obj = cls.from_config(
666 cls_config,
667 custom_objects=dict(
668 list(_GLOBAL_CUSTOM_OBJECTS.items()) +
669 list(custom_objects.items())))
670 else:
671 with CustomObjectScope(custom_objects):
File /opt/conda/lib/python3.10/site-packages/tensorflow/python/keras/engine/training.py:2383, in Model.from_config(cls, config, custom_objects)
2380 from tensorflow.python.keras.engine import functional # pylint: disable=g-import-not-at-top
2381 with generic_utils.SharedObjectLoadingScope():
2382 input_tensors, output_tensors, created_layers = (
-> 2383 functional.reconstruct_from_config(config, custom_objects))
2384 # Initialize a model belonging to cls
, which can be user-defined or
2385 # Functional
.
2386 model = cls(inputs=input_tensors, outputs=output_tensors,
2387 name=config.get('name'))
File /opt/conda/lib/python3.10/site-packages/tensorflow/python/keras/engine/functional.py:1279, in reconstruct_from_config(config, custom_objects, created_layers)
1277 # First, we create all layers and enqueue nodes to be processed
1278 for layer_data in config['layers']:
-> 1279 process_layer(layer_data)
1280 # Then we process nodes in order of layer depth.
1281 # Nodes that cannot yet be processed (if the inbound node
1282 # does not yet exist) are re-enqueued, and the process
1283 # is repeated until all nodes are processed.
1284 while unprocessed_nodes:
File /opt/conda/lib/python3.10/site-packages/tensorflow/python/keras/engine/functional.py:1264, in reconstruct_from_config..process_layer(layer_data)
1261 layer = deserialize_layer(layer_data, custom_objects=custom_objects)
1262 created_layers[layer_name] = layer
-> 1264 node_count_by_layer[layer] = int(_should_skip_first_node(layer))
1266 # Gather layer inputs and convert to ListWrapper
objects.
1267 inbound_nodes_data = layer_data['inbound_nodes']
File /opt/conda/lib/python3.10/site-packages/tensorflow/python/keras/engine/functional.py:1090, in _should_skip_first_node(layer)
1086 """Returns True if the first layer node should not be saved or loaded."""
1087 # Networks that are constructed with an Input layer/shape start with a
1088 # pre-existing node linking their input to output. This node is excluded from
1089 # the network config.
-> 1090 if layer._self_tracked_trackables:
1091 return (isinstance(layer, Functional) and
1092 # Filter out Sequential models without an input shape.
1093 isinstance(layer._self_tracked_trackables[0],
1094 input_layer_module.InputLayer))
1095 else:
AttributeError: 'ImageNetPreprocess' object has no attribute '_self_tracked_trackables'