Home > Blockchain >  SavedModel file does not exist error while converting vgg16
SavedModel file does not exist error while converting vgg16

Time:01-31

I want to convert rcmalli_vggface_tf_vgg16.h5 pre-trained model to js format to use in a tensorflow-js project.

to convert this file I tried different ways but yet I could not to solve the problem.

I'm using converters.convert_tf_saved_model method to load and then convert it to a json file.

converters.convert_tf_saved_model('rcmalli_vggface_tf_vgg16.h5','web_model')

But every time following error is shown:

SavedModel file does not exist at: rcmalli_vggface_tf_vgg16.h5

While I am sure the h5 file is next to the file that is running the program.

I try full path address but same error occured. I do not know what is problem

CodePudding user response:

You are converting a keras saved_model but the model is a keras layers_model because it is stored in h5 file.

I find this way the simplest to convert the model. And it did it in about 2 seconds.

  1. Go to TensorflowJS converter Github
  2. Follow installation instructions
  3. Download the model you point to from the Github repo.
    • The model is written in the HDF5 file format
    • By the way, this is the oldest of the models, why not to download a new one ?
    • Also, this is a huge model, unless runs on the server it is of no use for a browser (produces 50 shard files of 4MB.)
  4. Perform the conversion*
tensorflowjs_converter --input_format=keras rcmalli_vggface_tf_vgg16.h5 ./converted
  1. The output will then be a layers model, and this has to be loaded with the tf.loadLayers API.
  2. For example, use const model = await tf.loadGraphModel('path/to/model.json');

Note*: ./converted is the output directory, be sure not to overwrite your own stuff.

  • Related