Skip to content

Converting *.h5 model with tfjs #8734

Description

@m4rtin1

I am working on a project where I need to convert my *.h5 model to use it with javascript, I wanted to convert the model with tensorflowjs using the code:

import tensorflowjs as tfjs
tfjs.converters.save_keras_model(model, "tfjs_models")

an error occured saying something about deprecated np.object type. I fixed this error by replacing np.object with object in file: /venv/lib/python3.13/site-packages/tensorflowjs/write_weights.py and /venv/lib/python3.13/site-packages/tensorflowjs/read_weights.py on lines 27 and 28.
But it did not help.

A new error saying module 'tensorflow.compat.v1' has no attribute 'estimator'

my system information

  • fedora linux 44
  • python 3.13.14
  • pip 26.1.2
  • tensorflow 2.21.0
  • tensorflowjs 3.18.0
  • keras 3.15.0

Activity

  1. self-assigned this
    on Jul 20, 2026
  2. nileshau-afk commented on Jul 21, 2026

    @nileshau-afk

    Hi @m4rtin1 ,

    Thank you for raising this issue. We have reproduced the issue. As a workaround, you can downgrade to TensorFlow < 2.16 (which includes np.object) and NumPy < 1.24 (which includes the tf.estimator API) to ensure full compatibility with tensorflowjs. Alternatively, if you need to use newer versions of TensorFlow and NumPy, you can apply runtime monkey-patching in your Python script prior to importing tensorflowjs.

    Could you please try this and let us know if it works for you. If it doesn't, please share a code snippet we can run so we can pinpoint the issue.

  3. google-ml-butler commented on Jul 21, 2026

    @google-ml-butler

    Are you satisfied with the resolution of your issue?
    Yes
    No

  4. m4rtin1 commented on Jul 26, 2026

    @m4rtin1
    Author

    Hi @m4rtin1 ,

    Thank you for raising this issue. We have reproduced the issue. As a workaround, you can downgrade to TensorFlow < 2.16 (which includes np.object) and NumPy < 1.24 (which includes the tf.estimator API) to ensure full compatibility with tensorflowjs. Alternatively, if you need to use newer versions of TensorFlow and NumPy, you can apply runtime monkey-patching in your Python script prior to importing tensorflowjs.

    Could you please try this and let us know if it works for you. If it doesn't, please share a code snippet we can run so we can pinpoint the

    @nileshau-afk
    Thank for your reply
    I tried the using older versions of tensorflow and numpy, and it worked but with some additional debugging and version management.

    Is there a future fix for this issue, or other alternative that are error free or something like this.

  5. nileshau-afk commented on Jul 30, 2026

    @nileshau-afk

    Hi @m4rtin1 ,

    Thank you for sharing this context and bringing it back to our attention. We truly appreciate you flagging this issue, and we will file a bug internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions