Tfjs: Retrain image detection with MobileNet for use in TFjs, failure in tensorflowjs_converter

Created on 9 May 2019  路  4Comments  路  Source: tensorflow/tfjs

TensorFlow.js version

'1.0.1'
(retrain.py did not work with tf-nightly-2.0, so that was run with '1.13.1 ('v1.13.1-0-g6612da8951')'. Installing tensorflowjs-converter then installed tf-nightly-2.0-preview-2.0.0.dev20190509)

Browser version

n.a.

Describe the problem or feature request

Both tutorials at https://www.tensorflow.org/hub/tutorials/image_retraining and
https://www.tensorflow.org/tutorials/images/hub_with_keras about retraining a model mention but do not describe conversion to mobile models. Yet, conversion using tensorflowjs_converter failed in every attempt. https://stackoverflow.com/questions/55849309/retrain-image-detection-with-mobilenet mentions two attempts by me as well as questions by others with the same problem.

Code to reproduce the bug / link to feature request

and github issues

converter

Most helpful comment

Hi @serv-inc
I encountered the same problem and it seems that we use the wrong method.
There are loadGraphModel for TF converted models and loadLayersModel for Keras ones

All 4 comments

cc @pyu10055

The resulting model failed to load with

'className' and 'config' must set.[sic]
at new ValueError (/tmp/node_modules/@tensorflow/tfjs-layers/dist/errors.js:68:28)
at Object.deserializeKerasObject (/tmp/node_modules/@tensorflow/tfjs-layers/dist/utils/generic_utils.js:241:19)
at Object.deserialize (/tmp/node_modules/@tensorflow/tfjs-layers/dist/layers/serialization.js:29:28)
at /tmp/node_modules/@tensorflow/tfjs-layers/dist/models.js:290:45
at step (/tmp/node_modules/@tensorflow/tfjs-layers/dist/models.js:54:23)
at Object.next (/tmp/node_modules/@tensorflow/tfjs-layers/dist/models.js:35:53)
at fulfilled (/tmp/node_modules/@tensorflow/tfjs-layers/dist/models.js:26:58)

when called as tf.loadLayersModel("file:///tmp/web_model/model.json")

Hi @serv-inc
I encountered the same problem and it seems that we use the wrong method.
There are loadGraphModel for TF converted models and loadLayersModel for Keras ones

Was this page helpful?
0 / 5 - 0 ratings