11

I'd like to convert keras model to tensorflow.js model. I run the offical command :

tensorflowjs_converter --input_format keras \
                       path/to/my_model.h5 \
                       path/to/tfjs_target_dir

-bash: tensorflowjs_converter: command not found

How can I solve the problem?

lyzMaster
  • 530
  • 1
  • 6
  • 17

4 Answers4

9

I try to install the tensorflowjs library by using:

 $ sudo pip install tensorflowjs

instead of

$ pip install tensorflowjs

and run

$ tensorflowjs_converter --input_format keras \
                        path/to/my_model.h5 \
                        path/to/tfjs_target_dir

it's running!

lyzMaster
  • 530
  • 1
  • 6
  • 17
3

In my case folder with Python binaries was not added to PATH. You can either add it to PATH or run the binary using absolute path. The following command gives the path to current Python installation you are using:

$ python -m site --user-base
/Users/me/Library/Python/2.7

Binaries will be stored in bin sub-dir (you can add it to PATH):

/Users/me/Library/Python/2.7/bin

To run binary using absolute path simply add a binary name tensorflowjs_converter:

$ /Users/me/Library/Python/2.7/bin/tensorflowjs_converter ...
Michael Radionov
  • 12,859
  • 1
  • 55
  • 72
3

In my case creating a clean conda environment helped(pyenv doesn't suuport Windows). Make sure to use python version 3.6.8. Than activate new env and install tensorflowjs:

conda create -n tfjs python=3.6.8
conda activate tfjs
pip install tensorflowjs

It did the trick for me.

Serhiy
  • 4,357
  • 5
  • 37
  • 53
0

You should install tensorflowjs library using pip install tensorflowjs and you better read the below documentation. https://js.tensorflow.org/tutorials/import-keras.html

Bibin Jaimon
  • 534
  • 1
  • 6
  • 15