tensorflow / tfjs

A WebGL accelerated JavaScript library for training and deploying ML models.
https://js.tensorflow.org
Apache License 2.0
18.37k stars 1.92k forks source link

How can I load a tfjs model into python using keras or tensorflow or another standard tool? #623

Closed thebeancounter closed 6 years ago

thebeancounter commented 6 years ago

To get help from the community, check out our Google group.

TensorFlow.js version

Browser version

Describe the problem or feature request

Code to reproduce the bug / link to feature request

bileschi commented 6 years ago

Hello thebeancounter Assuming you are using the layers api within TFJS, you should be able to convert your tfjs model into keras.h5 format, and then load it in python.

Here are instructions for the converter, please note the "Format conversions support table". https://github.com/tensorflow/tfjs-converter

More detail at your S/O question here: https://stackoverflow.com/questions/51948810/how-to-load-tfjs-model-into-python-using-keras-tensorflow/51958601?noredirect=1#comment90873554_51958601

vishal0021 commented 4 years ago

hello i am trying to convert a tf.js model which is trained using google teachable machine. i want to convert the model in .h5 format so that i can load it with python keras. can you share some example to do the same

bileschi commented 4 years ago

Hello @vishal0021 , Do any of the code snippets at https://js.tensorflow.org/api/latest/#tf.LayersModel.save work for you?

hollowgalaxy commented 4 years ago

@bileschi so if I do in js tf.LayersModel.save(...) and save it locally. Then I can load that model in python, with tf.keras.load_model(...) Am I understanding that correctly?

bileschi commented 4 years ago

Yes but you may need to use the tfjs converter to change to a compatible format. https://github.com/tensorflow/tfjs/tree/master/tfjs-converter

On Fri, Jan 31, 2020 at 3:11 PM hollowgalaxy notifications@github.com wrote:

@bileschi https://github.com/bileschi so if I do in js tf.LayersModel.save(...) and save it locally. Then I can load that model in python, with tf.keras.load_model(...) Am I understanding that correctly?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/tfjs/issues/623?email_source=notifications&email_token=AAEFSTU5DQ3553EGCLGG6Y3RASAYVA5CNFSM4FQWX432YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKP3PVQ#issuecomment-580892630, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEFSTTGLFCE25SN2CFW72LRASAYVANCNFSM4FQWX43Q .

-- Stan Bileschi Ph.D. | SWE | bileschi@google.com | 617-230-8081

irfans4536 commented 3 years ago

hello i am trying to convert a tf.js model which is trained using google teachable machine. i want to convert the model in .h5 format so that i can load it with python keras. can you share some example to do the same

bro any answers