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

tfjs converter - not sure succesful or not #8375

Closed
nurulaqilah2207 opened this issue Sep 12, 2024 · 7 comments
Closed

tfjs converter - not sure succesful or not #8375

nurulaqilah2207 opened this issue Sep 12, 2024 · 7 comments

Comments

@nurulaqilah2207
Copy link

Please make sure that this is a build/installation issue. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:build_template

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): (GNU/Linux 5.15.153.1-microsoft-standard-WSL2 x86_64
  • TensorFlow.js installed from (npm or script link): pip install
  • TensorFlow.js version: 4.21.0
  • CUDA/cuDNN version: 12.3/8.9.7

Describe the problem
I want to convert my .h5 model to .js . Then, I get this output:
failed to lookup keras version from the file,
this is likely a weight only file
I do see there is a new folder consist of model.js and several .bin files. But I am not sure when I deploy the model, will it have any issue.

Provide the exact sequence of commands / steps that you executed before running into the problem
!tensorflowjs_converter --input_format=keras --output_format=tfjs_layers_model /home/usr/model_densenet121_2.h5 /home/usr/tfjs_model

Any other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

@shmishra99
Copy link
Contributor

Hi @nurulaqilah2207,

Currently, Keras models created with TensorFlow version 2.16 or higher are not supported by tfjs-converter. To resolve this issue, you may need to downgrade your TensorFlow and TensorFlow Decision Forests versions using the following commands:

!pip install tensorflow==2.15.0
!pip install tensorflow_decision_forests==1.8.1

Please let me know if this troubleshooting step resolves your issue with converting your Keras model (.h5) to a tfjs model (.json). If the issue persists after downgrading, kindly share your .h5 file so that we can reproduce and investigate the problem further.

Thank You!!

@nurulaqilah2207
Copy link
Author

Hi @shmishra99 ,
I've tried using tensorflow version 2.15.0, and still get the same output
failed to lookup keras version from the file,
this is likely a weight only file

this is link to my .h5 file file

@shmishra99
Copy link
Contributor

Hi @nurulaqilah2207 ,

I apologize for the delay in my response. I am able to convert the Keras model file you shared to a tfjsmodel. You can follow this gist: gist

Steps:

  1. Upload your model to the sample_data folder.
  2. Install the dependencies mentioned in the notebook.
  3. Run the converter command from the cell.

This will give you the following output:

image

Let me know if it is resolving your issue.

Thank You.

@nurulaqilah2207
Copy link
Author

hi @shmishra99,

Thank you for your help! I've tried again and able to convert the model.
But I do have one question, if I train the model using tensorflow version 2.16 or higher, will I still able to convert the model after downgrade tensorflow version?

@shmishra99
Copy link
Contributor

Hi @nurulaqilah2207 ,

You can convert models saved with TensorFlow 2.16 or higher or Keras 3. However, models saved with tensorFlow 2.16 does not save the expected input size. So, you cannot load the converted model as a layer model. You must load it as a graph model.

Thank You!!

@nurulaqilah2207
Copy link
Author

Okay, understand on that. Thank you so much for your help and response.

Copy link

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

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

2 participants