Tfjs: error when running "yarn watch" Uncaught (in promise) TypeError: Cannot read property 'drawImage' of null

Created on 27 May 2018  路  10Comments  路  Source: tensorflow/tfjs

I am using the code as explained here:
and getting the following error on the init method

Uncaught (in promise) TypeError: Cannot read property 'drawImage' of null
at MathBackendWebGL.fromPixels (backend_webgl.js:134)
at Engine.fromPixels (engine.js:293)
at ArrayOps.fromPixels (array_ops.js:280)
at operation.js:9
at Tracking.tidy (tracking.js:34)
at Object.descriptor.value (operation.js:9)
at webcam.js:37
at Object.Tracking.tidy (tracking.js:34)
at Webcam.capture (webcam.js:35)
at index.js:163

When I am running the demo from the link in the tutorial it works fine. maybe a new version?

Most helpful comment

v10.3 works. I can't get v11.2 to work

All 10 comments

I have same error.
Using posenet and build with webpack4.

{
  "@tensorflow-models/posenet": "^0.0.1",
  "@tensorflow/tfjs": "^0.11.2",
}

Uncaught (in promise) TypeError: Cannot read property 'drawImage' of null
at MathBackendWebGL.fromPixels (backend_webgl.js?88b1:134)
at Engine.fromPixels (engine.js?b385:293)
at ArrayOps.fromPixels (array_ops.js?4147:280)
at eval (operation.js?1a9f:9)
at Tracking.tidy (tracking.js?40da:34)
at Object.descriptor.value (operation.js?1a9f:9)
at toInputTensor (posenet.js?6236:46)
at eval (posenet.js?6236:100)
at Object.Tracking.tidy (tracking.js?40da:34)
at PoseNet.eval (posenet.js?6236:99)

Does anyone have a solution?

Hi,

I started investigating the issue and I can confirm I am able to reproduce it.
To be more specific, I tried different tfjs versions and the issue appeared when upgrading from tfjs 0.10.3 to 0.11.0.
This is the problematic line: https://github.com/tensorflow/tfjs-core/blob/fd49f546e8eb80faf662ef6bab66176b03041cd7/src/kernels/backend_webgl.ts#L138, since 0.11.0, getContext('2d') returns null.

@thebeancounter While waiting for a fix, what I temporary suggest: remove your node_modules folder, change tfjs version to 0.10.3 in your package.json, it will work. @ymkz you should try the same thing, I can't guarantee it will work, I did not try with the posenet example.

Edit: It looks like @dsmilkov fixed the issue in tfjs-core: https://github.com/tensorflow/tfjs-core/pull/1064

v10.3 works. I can't get v11.2 to work

@hpssjellis Downgrading to v0.10.3 worked for me as well thank you very much!

Same, I stuck to v0.10.3 since its the version they use in the posenet working camera and coco demos.

@timotheebernard thank you for investigating. I tried to downgrade tfjs 0.10.3 and it was worked well, thanks!

I updated all the tfjs-examples to use 0.11.4 where that error should be fixed (it was fixed in tensorflow/tfjs-core#1064). Will close this issue, but feel free to reopen if you again run into the issue. Make sure to use tfjs >= 0.11.4

10.3 worked with rebuild but 11.4 needs extra dependencies

@zakobyte, can you elaborate on that a bit? I'm assuming you pulled from master and re-run yarn to install the extra dependencies. Did it not work after that?

Tensoeflowjs Version 11.4 works for my webpage using Posenet. Thanks for fixing it @dsmilkov

Was this page helpful?
0 / 5 - 0 ratings