tfjs icon indicating copy to clipboard operation
tfjs copied to clipboard

Frozen Model conversion issues

Open qzcsgs opened this issue 7 years ago • 4 comments

When converting Frozen Model, a pb file and a JSON file and a group1-shard1of1 file will be generated. Is this normal?

The format in the JSON file is like this

[
  {
    "path": [],
    "weights": []
  }
]

tensorflowjs 0.8.6

qzcsgs avatar Aug 30 '19 03:08 qzcsgs

Yes that is expected given that version of TensorFlow.js you are using. Newer versions do not produce the pb file.

tafsiri avatar Aug 30 '19 14:08 tafsiri

To converter a frozen model and be compatible with the latest tfjs version, use the following steps:

  1. I have a model formatted as a Session bundle or Frozen model. How do I convert it to TensorFlow.js?

You can install a previous version of TensorFlow.js in a virtual environment to convert the model to the JSON format. Here is how you can achieve this.

  • Set up the virtual environment:

virtualenv --no-site-packages venv. venv/bin/activate pip install tensorflowjs==0.8.6

venv is the name of the virtual environment.

  • Convert a session bundle model:

tensorflowjs_converter
--input_format=tf_session_bundle
--output_json=true
--output_node_names='MobilenetV1/Predictions/Reshape_1'
/mobilenet/session_bundle
/mobilenet/web_model

  • Convert a frozen model:

tensorflowjs_converter
--input_format=tf_frozen_model
--output_json=true
--output_node_names='MobilenetV1/Predictions/Reshape_1'
--saved_model_tags=serve
/mobilenet/frozen_model.pb
/mobilenet/web_model

On Mon, Sep 2, 2019 at 11:23 AM 曲智超 [email protected] wrote:

@tafsiri https://github.com/tafsiri So how to use them?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tensorflow/tfjs/issues/1945?email_source=notifications&email_token=AAAA7MSNTDGYDHD7VR2IAS3QHSBJPA5CNFSM4ISI4CKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5UTFXQ#issuecomment-526987998, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAA7MV6YW4J44VOSSVKL3LQHSBJPANCNFSM4ISI4CKA .

pyu10055 avatar Sep 03 '19 07:09 pyu10055

For Converting Frozen_inference_model.pb to tensroflowjs(model.json) : Please Refer this Link : https://github.com/tensorflow/tfjs-models/blob/master/deeplab/scripts/convert_deeplab.sh

haleemik avatar Feb 13 '21 16:02 haleemik

For Converting Frozen_inference_model.pb to tensroflowjs(model.json) : Please Refer this Link : https://github.com/tensorflow/tfjs-models/blob/master/deeplab/scripts/convert_deeplab.sh

tensorflowjs_converter
--input_format=tf_frozen_model
--output_json=true
--saved_model_tags=serve
--output_node_names='SemanticPredictions'
--quantization_bytes 2
frozen_inference_graph.pb
$OUTPUT_DIR

haleemik avatar Feb 13 '21 16:02 haleemik