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.

`fromPixels` returns invalid values for `webgpu` backend

See original GitHub issue

i’ve noticed some errors during model execution, so went back to check inputs and it seems that fromPixels returns incorrect values for webgpu backend

await tf.setBackend('webgpu');
// input is a canvas which is a copy of a webcam input in 1280x720 resolution
const buffer = await tf.browser.fromPixelsAsync(canvas);
const data = await buffer.data();
for (let idx = 0; idx < data.length; idx++) {
  if (data[idx] < 0 || data[idx] > 255) console.log({ idx, val: data[idx], length: data.length });
}
{idx: 1094922, val: -1, length: 2764800}
{idx: 1094925, val: -1, length: 2764800}
{idx: 2275694, val: -1, length: 2764800}

i cannot think of any scenario where pixel value of -1 is a valid thing to have,
especially on only 3 random pixels out of entire (otherwise valid) image
note that invalid values do not occur on every frame, but it does happen often enough

processing the same input shows no such problems when using webgl backend

environment: tfjs 3.20.0, tfjs-backend-webgpu 0.0.1-alpha.13, chrome canary 107

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
qjia7commented, Sep 28, 2022

@shaoboyan Please file a chromium/dawn bug to trace the GPUExternalTexture issue. And this issue will be blocked by that one. @vladmandic To continue to use fromPixels with video, you can set flag WEBGPU_IMPORT_EXTERNAL_TEXTURE to false. In this path, it will package the video to canvas and then call copyExternalImageToTexture() to do the following thing.

1reaction
vladmandiccommented, Sep 28, 2022

@shaoboyan live link i’ve posted (https://vladmandic.github.io/nudenet/src/verify.html, sorry there was a typo in the url) includes a sample video. its only 10sec long, but on my system it generates thousands of errors per frame - and it logs to browser console.

example:

{tf: '3.20.0', backend: 'webgpu', available: {…}, flags: {…}}
{mediaTime: 0.64, errors: 44492, videoData: Int32Array(8294400), canvasData: Int32Array(8294400)}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Creates a tf.Tensor with the provided values, shape and dtype.
createElement('canvas'); const customBackend = new tf. ... Returns: void ... For WebGPU backend, the data will be stored on a buffer. There is...
Read more >
How to activate webgpu backend on Tensorflow.JS
getBackend () I get webgl even with Chrome Canary with WEBGPU enabled. Also running tf.backend() doesn't seem to indicate that WEBGPU is there....
Read more >
Deep Learning in the Browser - Exploring TF.js, WebDNN and ...
WebDNN supports 4 execution backend implementations: WebMetal, WebGL, WebAssembly, and fallback pure javascript implementation.
Read more >
WebGPU - W3C
2.1.1 CPU-based undefined behavior; 2.1.2 GPU-based undefined behavior; 2.1.3 Uninitialized data; 2.1.4 Out-of-bounds access in shaders; 2.1.5 Invalid data ...
Read more >
What are the limitations of TensorFlow JS? - Quora
... advantages: the infrastructure and set of requirements are simplified as the need for background API requests is removed; the available data is...
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