Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
OysterQAQ opened this issue Sep 14, 2023 · 2 comments

Comments

@OysterQAQ
Copy link

OysterQAQ commented Sep 14, 2023

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.

@OysterQAQ OysterQAQ added the type:bug Something isn't working label Sep 14, 2023
@gaikwadrahul8 gaikwadrahul8 self-assigned this Sep 14, 2023
@gaikwadrahul8
Copy link
Contributor

Hi, @OysterQAQ

Thank you for bringing this issue to our attention and I was trying to replicate the same issue with tfjs-model which you provided in the issue template and I'm also getting same error which you mentioned above so we'll have to dig more into this issue and will update you soon. Thank you!

For your reference I have added error log output :

gaikwadrahul-macbookpro:test-7960 gaikwadrahul$ node index.js

============================
Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, visit https://github.com/tensorflow/tfjs-node for more details. 
============================
111
/Users/gaikwadrahul/Desktop/TFJS/test-7960/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4522
        var srcBackend = info.backend;
                              ^

TypeError: Cannot read properties of undefined (reading 'backend')
    at Engine.moveData (/Users/gaikwadrahul/Desktop/TFJS/test-7960/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4522:31)
    at DataStorage.get (/Users/gaikwadrahul/Desktop/TFJS/test-7960/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:230:28)
    at MathBackendCPU.incRef (/Users/gaikwadrahul/Desktop/TFJS/test-7960/node_modules/@tensorflow/tfjs-backend-cpu/dist/tf-backend-cpu.node.js:292:36)
    at Object.reshape [as kernelFunc] (/Users/gaikwadrahul/Desktop/TFJS/test-7960/node_modules/@tensorflow/tfjs-backend-cpu/dist/tf-backend-cpu.node.js:3825:13)
    at kernelFunc (/Users/gaikwadrahul/Desktop/TFJS/test-7960/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4707:32)
    at /Users/gaikwadrahul/Desktop/TFJS/test-7960/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4767:27
    at Engine.scopedRun (/Users/gaikwadrahul/Desktop/TFJS/test-7960/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4572:23)
    at Engine.runKernelFunc (/Users/gaikwadrahul/Desktop/TFJS/test-7960/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4763:14)
    at Engine.runKernel (/Users/gaikwadrahul/Desktop/TFJS/test-7960/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4636:21)
    at reshape_ (/Users/gaikwadrahul/Desktop/TFJS/test-7960/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:9638:19)

Node.js v18.17.0
gaikwadrahul-macbookpro:test-7960 gaikwadrahul$ 

@OysterQAQ
Copy link
Author

Is there any progress?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@mattsoulanille @OysterQAQ @gaikwadrahul8 and others