question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[tfjs-tflite] ERROR: failed to delegate CONV_2D node #2

See original GitHub issue

System information

  • OS Platform and Distribution: Ubuntu 20.04
  • Browser version: Chrome 92

The following code fails with a bunch of errors:

<img id="imgInputEl" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEBOgE6AAD/4gIoSUNDX1BST0ZJTEUAAQEAAAIYAAAAAAIQAABtbnRyUkdCIFhZWiAAAAAAAAAAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAAHRyWFlaAAABZAAAABRnWFlaAAABeAAAABRiWFlaAAABjAAAABRyVFJDAAABoAAAAChnVFJDAAABoAAAAChiVFJDAAABoAAAACh3dHB0AAAByAAAABRjcHJ0AAAB3AAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAFgAAAAcAHMAUgBHAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFhZWiAAAAAAAABvogAAOPUAAAOQWFlaIAAAAAAAAGKZAAC3hQAAGNpYWVogAAAAAAAAJKAAAA+EAAC2z3BhcmEAAAAAAAQAAAACZmYAAPKnAAANWQAAE9AAAApbAAAAAAAAAABYWVogAAAAAAAA9tYAAQAAAADTLW1sdWMAAAAAAAAAAQAAAAxlblVTAAAAIAAAABwARwBvAG8AZwBsAGUAIABJAG4AYwAuACAAMgAwADEANv/bAEMACgcHCAcGCggICAsKCgsOGBAODQ0OHRUWERgjHyUkIh8iISYrNy8mKTQpISIw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flite@0.0.1-alpha.4/dist/tf-tflite.js"></script>

<script>
  (async function() {
    const esrgan = await tflite.loadTFLiteModel('https://tfhub.dev/captain-pool/lite-model/esrgan-tf2/1');
    console.log("esrgan:", esrgan);

    const outputTensor = tf.tidy(() => {
      let img = tf.browser.fromPixels(imgInputEl);
      let input = tf.sub(tf.div(tf.expandDims(img), 127.5), 1); // normalise [-1,1]
      console.log("input:", input);
      
      let outputTensor = esrgan.predict(input);
      return tf.mul(tf.add(outputTensor, 1), 127.5) // de-normalize
    });
    console.log(outputTensor, outputTensor.shape);
  })();
</script>

imageimage

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jinjingforevercommented, Aug 26, 2021

Thank you guys for investigation. Actually tfjs-tflite@0.0.1-alpha.4 is indeed the latest version. The errors shown here are from the tflite c++ runtime. It is likely that the model is not working well with XNNPACK that tflite is using. I will do more digging with the tflite team and report back if I have anything. Thank you!

1reaction
jinjingforevercommented, Sep 3, 2021

Hi, I just published a new version of the tfjs-tflite package (0.0.1-alpha.6) which should fix this problem. See this demo. The model is a little bit slow but it works:) It might get a bit faster if you set up your server for cross-origin isolation (codepen doesn’t support it unfortunately).

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Request to have ConvLSTM2D for TFLite #38220 - GitHub
java.lang.IllegalArgumentException: Internal error: Failed to apply delegate: Attempting to use a delegate that only supports static-sized ...
Read more >
TFLite Converter: Conv2D error when converting
Here is the code snippet I used: converter = tf.lite.TFLiteConverter.from_saved_model(self.tf_model_path) ...
Read more >
tensorflow/tfjs-node: Error: Failed to load SavedModel: Op ...
The error received is due to the lack of ops available on raspberry pi when loading a desktop compiled model (with higher ops...
Read more >
Hexagon delegate on RB5 - Qualcomm Developer Network
I've tried to run a tflite model with hexagon delegate on Qualcomm RB5. ... ERROR: Node number 31 (TfLiteHexagonDelegate) failed to prepare.
Read more >
Use Coral Edge TPUs to run TFlite models in Node with ...
A fully working version of this Codelab is available in the sig-tfjs GitHub repo. Do I need a Coral Device? No. You can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found