Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Not able usee #51

Open
Open

Description

Thanks for providing good model for image rotation. I would like to use it. But I could not use it. I have updated imports for keras so that it is inside tensorflow. I have copied model and run it in google vertex AI and getting this error. Can you please help?


ValueError Traceback (most recent call last)

Cell In[32], line 2

 1 model_location = os.path.join('rotnet', 'models', 'rotnet_street_view_resnet50.hdf5')

----> 2 model = load_model(model_location, custom_objects={'angle_error': angle_error})

File /opt/conda/lib/python3.10/site-packages/keras/src/saving/saving_api.py:183, in load_model(filepath, custom_objects, compile, safe_mode)

176 return saving_lib.load_model(
177 filepath,
178 custom_objects=custom_objects,
179 compile=compile,
180 safe_mode=safe_mode,
181 )
182 if str(filepath).endswith((".h5", ".hdf5")):

--> 183 return legacy_h5_format.load_model_from_hdf5(filepath)

184 elif str(filepath).endswith(".keras"):
185 raise ValueError(
186 f"File not found: filepath={filepath}. "
187 "Please ensure the file is an accessible `.keras` "
188 "zip file."
189 )

File /opt/conda/lib/python3.10/site-packages/keras/src/legacy/saving/legacy_h5_format.py:133, in load_model_from_hdf5(filepath, custom_objects, compile)

130 model_config = json_utils.decode(model_config)
132 with saving_options.keras_option_scope(use_legacy_config=True):

--> 133 model = saving_utils.model_from_config(

134 model_config, custom_objects=custom_objects
135 )
137 # set weights
138 load_weights_from_hdf5_group(f["model_weights"], model)

File /opt/conda/lib/python3.10/site-packages/keras/src/legacy/saving/saving_utils.py:85, in model_from_config(config, custom_objects)

 81 # TODO(nkovela): Swap find and replace args during Keras 3.0 release
 82 # Replace keras refs with keras
 83 config = _find_replace_nested_dict(config, "keras.", "keras.")

---> 85 return serialization.deserialize_keras_object(

 86 config,
 87 module_objects=MODULE_OBJECTS.ALL_OBJECTS,
 88 custom_objects=custom_objects,
 89 printable_module_name="layer",
 90 )

File /opt/conda/lib/python3.10/site-packages/keras/src/legacy/saving/serialization.py:495, in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)

490 cls_config = _find_replace_nested_dict(
491 cls_config, "keras.", "keras."
492 )
494 if "custom_objects" in arg_spec.args:

--> 495 deserialized_obj = cls.from_config(

496 cls_config,
497 custom_objects={
498 **object_registration.GLOBAL_CUSTOM_OBJECTS,
499 **custom_objects,
500 },
501 )
502 else:
503 with object_registration.CustomObjectScope(custom_objects):

File /opt/conda/lib/python3.10/site-packages/keras/src/models/model.py:492, in Model.from_config(cls, config, custom_objects)

487 if is_functional_config and revivable_as_functional:
488 # Revive Functional model
489 # (but not Functional subclasses with a custom __init__)
490 from keras.src.models.functional import functional_from_config

--> 492 return functional_from_config(

493 cls, config, custom_objects=custom_objects
494 )
496 # Either the model has a custom __init__, or the config
497 # does not contain all the information necessary to
498 # revive a Functional model. This happens when the user creates

(...)

501 # In this case, we fall back to provide all config into the
502 # constructor of the class.
503 try:

File /opt/conda/lib/python3.10/site-packages/keras/src/models/functional.py:503, in functional_from_config(cls, config, custom_objects)

501 # First, we create all layers and enqueue nodes to be processed
502 for layer_data in config["layers"]:

--> 503 process_layer(layer_data)

505 # Then we process nodes in order of layer depth.
506 # Nodes that cannot yet be processed (if the inbound node
507 # does not yet exist) are re-enqueued, and the process
508 # is repeated until all nodes are processed.
509 while unprocessed_nodes:

File /opt/conda/lib/python3.10/site-packages/keras/src/models/functional.py:483, in functional_from_config..process_layer(layer_data)

479 # Instantiate layer.
480 if "module" not in layer_data:
481 # Legacy format deserialization (no "module" key)
482 # used for H5 and SavedModel formats

--> 483 layer = saving_utils.model_from_config(

484 layer_data, custom_objects=custom_objects
485 )
486 else:
487 layer = serialization_lib.deserialize_keras_object(
488 layer_data, custom_objects=custom_objects
489 )

File /opt/conda/lib/python3.10/site-packages/keras/src/legacy/saving/saving_utils.py:85, in model_from_config(config, custom_objects)

 81 # TODO(nkovela): Swap find and replace args during Keras 3.0 release
 82 # Replace keras refs with keras
 83 config = _find_replace_nested_dict(config, "keras.", "keras.")

---> 85 return serialization.deserialize_keras_object(

 86 config,
 87 module_objects=MODULE_OBJECTS.ALL_OBJECTS,
 88 custom_objects=custom_objects,
 89 printable_module_name="layer",
 90 )

File /opt/conda/lib/python3.10/site-packages/keras/src/legacy/saving/serialization.py:473, in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)

470 if isinstance(identifier, dict):
471 # In this case we are dealing with a Keras config dictionary.
472 config = identifier

--> 473 (cls, cls_config) = class_and_config_for_serialized_keras_object(

474 config, module_objects, custom_objects, printable_module_name
475 )
477 # If this object has already been loaded (i.e. it's shared between
478 # multiple objects), return the already-loaded object.
479 shared_object_id = config.get(SHARED_OBJECT_KEY)

File /opt/conda/lib/python3.10/site-packages/keras/src/legacy/saving/serialization.py:354, in class_and_config_for_serialized_keras_object(config, module_objects, custom_objects, printable_module_name)

350 cls = object_registration.get_registered_object(
351 class_name, custom_objects, module_objects
352 )
353 if cls is None:

--> 354 raise ValueError(

355 f"Unknown {printable_module_name}: '{class_name}'. "
356 "Please ensure you are using a `keras.utils.custom_object_scope` "
357 "and that this object is included in the scope. See "
358 "https://www.tensorflow.org/guide/keras/save_and_serialize"
359 "#registering_the_custom_object for details."
360 )
362 cls_config = config["config"]
363 # Check if `cls_config` is a list. If it is a list, return the class and the
364 # associated class configs for recursively deserialization. This case will
365 # happen on the old version of sequential model (e.g. `keras_version` ==
366 # "2.0.6"), which is serialized in a different structure, for example
367 # "{'class_name': 'Sequential',
368 # 'config': [{'class_name': 'Embedding', 'config': ...}, {}, ...]}".

ValueError: Unknown layer: 'Convolution2D'. Please ensure you are using a keras.utils.custom_object_scope and that this object is included in the scope. See https://www.tensorflow.org/guide/keras/save_and_serialize#registering_the_custom_object for details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /