Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KerasHub model deserialization issue #20855

Closed
r-zip opened this issue Feb 4, 2025 · 2 comments
Closed

KerasHub model deserialization issue #20855

r-zip opened this issue Feb 4, 2025 · 2 comments

Comments

@r-zip
Copy link

r-zip commented Feb 4, 2025

I am attempting to follow the tutorial here and code snippets here, but when I run these snippets I get the following error message:

TypeError: <class 'keras_hub.src.models.resnet.resnet_backbone.ResNetBackbone'> could not be deserialized properly. Please ensure that components that are Python object instances (layers, models, etc.) returned by `get_config()` are explicitly deserialized in the model's `from_config()` method.

config={'module': 'keras_hub.src.models.resnet.resnet_backbone', 'class_name': 'ResNetBackbone', 'config': {'name': 'res_net_backbone', 'trainable': True, 'input_conv_filters': [64], 'input_conv_kernel_sizes': [7], 'stackwise_num_filters': [64, 128, 256, 512], 'stackwise_num_blocks': [3, 4, 6, 3], 'stackwise_num_strides': [1, 2, 2, 2], 'block_type': 'bottleneck_block', 'use_pre_activation': False, 'image_shape': [None, None, 3]}, 'registered_name': 'keras_hub>ResNetBackbone'}.

Exception encountered: unsupported operand type(s) for %: 'NoneType' and 'int'

I am running MacOS Sequoia 15.2 on a Macbook M1 Pro. The dependencies in my pyproject.toml look like:

dependencies = [
    "beartype",
    "cyclopts",
    "flax>=0.10.2",
    "hypothesis",
    "jax[cuda12]==0.4.28; sys_platform == 'linux'",
    "jax==0.4.28; sys_platform == 'darwin'",
    "jaxtyping",
    "jupyterlab",
    "kagglehub",
    "keras-cv>=0.9.0",
    "keras-hub-nightly>=0.19.0.dev202502030345",
    "keras-nightly>=3.8.0.dev2025020303",
    "matplotlib",
    "opencv-python",
    "optax",
    "scikit-image",
    "tensorflow~=2.18.0",
    "tqdm",
    "torch>=2.3.1",
    "torchvision>=0.18.1",
]

I have experimented with pinning/unpinning JAX and Keras versions to troubleshoot the issue, without any luck. This error occurs when using both JAX and PyTorch backends.

@dhantule
Copy link
Contributor

dhantule commented Feb 4, 2025

@r-zip, thanks for reporting this. Could you please open this issue in the Keras-Hub repo?

@r-zip
Copy link
Author

r-zip commented Feb 4, 2025

Sure. Sorry for misfiling it here.

@r-zip r-zip closed this as completed Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants