Closed aptlin closed 4 years ago
@pyu10055, it seems that I am missing something very obvious, since the conversion went smooth the first time I tried it more than two weeks ago (first converting to tf.keras, then to Saved Model, and only then to TF.js JSON) during which tensorflowjs
has switched to tensorflow==1.14.0
. With tf 1.14
, I cannot convert the model neither by this roundabout which I has simplified since then, nor by exporting the checkpoints to Saved Models straight away. I have also tried installing tf-nightly-2.0-preview==2.0.0.dev20190520
, tf-nightly-2.0-preview==2.0.0.dev20190601
and tf-nightly-2.0-preview==2.0.0.dev20190623
together with tensorflow==1.13.1
to reproduce the environment then, but to no avail.
Although it has not helped me in the end, there is a snippet of the tensorflowjs_converter
SavedModel utility which might make testing easier.
Here is the end of the convoluted but working roundabout to convert EfficientNet checkpoints to Saved Models.
@sdll Looks like the tensorflow function swish_f32 is missing from the saved model. Here is some discussion on this topic in tensorflow repo, https://github.com/tensorflow/tensorflow/issues/29574
Is this a keras model, and you saved with tf.keras? One suggestion from a colleague is to recreate the saved model using TF 1.14, maybe the function is unintentionally removed with other version.
@pyu10055, the latest version of the script makes no use of tf.keras. Indeed, I have tried exporting the checkpoint to SavedModel using TF 1.14, but had no success, since the attempt to restore the model in python using load (from tensorflow.python.saved_model.load import load
) fails with the missing op error. Could you please tell me if I need to load this op somehow during the export to SavedModel?
@pyu10055, the checkpoints themselves were generated using TF 1.13, it seems. I wonder whether this might cause problems.
Disabling eager execution like the issue suggested did not help.
can this model be loaded with TF 1.13?
Yes, I used the linked script to load the checkpoints and export a SavedModel which then at one point I converted to TF.js GraphModel without any issues. But then an attempt to use the converter failed due to the import error I mentioned above. I also tried different versions of tensorflowjs, but could not reproduce the successful conversion.
Closing this due to lack of activity, feel to reopen. Thank you
Bug Report
TensorFlow.js version
1.1.2 & 1.2.2.1
Browser version
n/a
Describe the problem or feature request
A humongous number of attempts (not all reflected in the commits) to tweak the script and convert the EfficientNet checkpoints exported to tf.SavedModel using
tensorflowjs==1.1.2
failed with the following error:UPDATE :: July 8, 11am UTC: Installing
tensorflowjs==1.2.1
fails in a clean virtual environment due toERROR: Could not find a version that satisfies the requirement tf-nightly-2.0-preview>=2.0.0.dev20190502 (from tensorflowjs==1.1.2) (from versions: none)
. Indeed, installing any version oftf-nightly-2.0-preview
fails now. UPDATE :: July 8, 2pm UTC: The cause of the problem above is the removal of the pre-built package oftf-nightly-2.0-preview
for OS X. Working in the Debian Docker container does not resolve the issue.Code to reproduce the bug
See the conversion script for EfficientNet.
Unfortunately, using
tensorflow >= 1.14
(and thustensorflowjs > 1.2.1
) does not work, since the converter fails with the following error:The full traceback is below:
UPDATE :: July 8, 5pm UTC: The converter has little to do with the problem when
tf 1.14.0
is used, since I cannot load the converted saved model back the way it is done in the source code: it fails with a similar trace. Loading withtf.saved_model.loader.load
works smoothly.However, I have successfully converted the EfficientNet checkpoints using
tensorflow < 1.14
, as you can see in the demo:The problem is that I can not reproduce the conversion now, leaving the PR in a limbo as a result.
Related issues
This one has some hacky solutions, but in the context of tf2.