Repository navigation
Converting *.h5 model with tfjs #8734
Description
Activity
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.
google-ml-butler commented
on Jul 21, 2026 More actionsHi @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.
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.
Reacted by MEDJEMADJ MOSSAAB
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
tensorflowjsusing the code:an error occured saying something about deprecated
np.objecttype. I fixed this error by replacingnp.objectwithobjectin file:/venv/lib/python3.13/site-packages/tensorflowjs/write_weights.pyand/venv/lib/python3.13/site-packages/tensorflowjs/read_weights.pyon lines 27 and 28.But it did not help.
A new error saying
module 'tensorflow.compat.v1' has no attribute 'estimator'my system information