Skip to content

A TensorFlow fully convolutional model with no fixed input size cannot run properly in TensorFlow.js. #7960

@OysterQAQ

Description

@OysterQAQ

Please make sure that this is a bug. As per our
GitHub Policy,
we only address code/doc bugs, performance issues, feature requests and
build/installation issues on GitHub. tag:bug_template

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js):yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):MacOs 13
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
  • TensorFlow.js installed from (npm or script link):4.11.0
  • TensorFlow.js version (use command below):2.13
  • Browser version:chrome 116.0.5845.187
  • Tensorflow.js Converter Version: 4.11.0

Describe the current behavior

When converting a TensorFlow SavedModel to a tfjs model using tensorflowjs_converter and running it on [email protected], I encountered the following errors:

Uncaught (in promise) Error: Incompatible shape during merge: 1,76,282,64 vs. 1,260,1084,64
In versions 4.4.0 to 4.11.0, I received the following error:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'backend')
The original model is a fully convolutional model with no fixed input dimensions, designed for image super-resolution. It runs well on TensorFlow. You can find the specific code at https://github.com/OysterQAQ/ACG2vec-model/blob/master/real-cugan_tf/upcunet_v3_tfjs.py.
SavedModel.zip
tfjs_model.zip

const test = async () => {

  await tf.setBackend('cpu');
  const model = await tf.loadGraphModel("./models/tfjs_model/model.json");

console.log(111);

  const inputTensor = tf.zeros([1,224, 3080, 3], 'int32');
  const outputTensor = await model.executeAsync(inputTensor);
  if (outputTensor) {
  console.log(outputTensor.dataSync());
} else {
  console.error('outputTensor is undefined');
}
  inputTensor.dispose();
  outputTensor.dispose();
 
}
test();

Describe the expected behavior

Standalone code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate
the problem. If possible, please share a link to Colab/CodePen/any notebook.

Other info / logs Include any logs or source code that would be helpful to
diagnose the problem. If including tracebacks, please include the full
traceback. Large logs and files should be attached.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions