tensorflow / tfjs

A WebGL accelerated JavaScript library for training and deploying ML models.
https://js.tensorflow.org
Apache License 2.0
18.51k stars 1.94k forks source link

Size mismatch of converted TF Saved Model to tfjs model #3695

Closed 11mhg closed 4 years ago

11mhg commented 4 years ago

To get help from the community, we encourage using Stack Overflow and the tensorflow.js tag.

TensorFlow.js version

{ 'tfjs-core': '2.0.1', 'tfjs-backend-cpu': '2.0.1', 'tfjs-backend-webgl': '2.0.1', 'tfjs-data': '2.0.1', 'tfjs-layers': '2.0.1', 'tfjs-converter': '2.0.1', tfjs: '2.0.1', 'tfjs-node': '2.0.1' }

Browser version

N/A, Using Node

Describe the problem or feature request

I have some model in tensorflow python which I have trained and saved as a TF Saved Model using the following line of code:

    tf.saved_model.save(model, './saved_models/REPainter',
                        signatures=model.call.get_concrete_function(
                            tf.TensorSpec(shape=[None,None,None,6], dtype=tf.float32)))

I can then load the model in python and predict using an arbitrary input size and it works fine in python:

model.signatures['serving_default'](tf.ones([1,416,416,6]))['output_0'].shape

However, once I convert to a tfjs model using this call:

tensorflowjs_converter --input_format=tf_saved_model --signature_name=serving_default --output_node_names=output_0 ./saved_models/REPainter ./tfjs_model/

My tfjs model cannot run. It seems as though it is infering incorrect shapes. To be specific, the following happens:

image

I have no clue what is causing this. Any clue?

pyu10055 commented 4 years ago

This could be related to strided_slice op, we have a fix for that in upcoming 2.1.0 release.

11mhg commented 4 years ago

Sounds good. I will give this a go with 2.1.0.

google-ml-butler[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 dyas if no further activity occurs. Thank you.

google-ml-butler[bot] commented 4 years ago

Closing as stale. Please @mention us if this needs more attention.

google-ml-butler[bot] commented 4 years ago

Are you satisfied with the resolution of your issue? Yes No