vladmandic / face-api

FaceAPI: AI-powered Face Detection & Rotation Tracking, Face Description & Recognition, Age & Gender & Emotion Prediction for Browser and NodeJS using TensorFlow/JS
https://vladmandic.github.io/face-api/demo/webcam.html
MIT License
850 stars 151 forks source link

Unhandled Promise Rejection: TypeError: null is not an object (evaluating 'e.isContextLost') #173

Closed hktalent closed 1 year ago

hktalent commented 1 year ago

$ cat package.json|grep tfjs

    "@tensorflow/tfjs": "4.7.0",
    "@tensorflow/tfjs-backend-wasm": "^4.9.0",
    "@tensorflow/tfjs-core": "^4.9.0",

$ node -v v20.4.0 $ uname -a Darwin 51pwn-2.local 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul 5 23:51:32 PDT 2023; root:xnu-8796.141.3~8/RELEASE_X86_64 x86_64

safari:Version 16.6 (18615.3.12.11.2) or chrome:Version 114.0.5735.198 (Official Build) (x86_64) Steps to Reproduce

yarn build out v8.js

<script src=/js/v8.js></script><script src=/js/face-api.min.js></script>

code:
faceapi.env.monkeyPatch({
        Canvas: window.ov8canvas,
        Image: oImgOcr,
        ImageData: szImageData,
    })

await faceapi.tf.enableProdMode()
    faceapi.tf.ENV['DEBUG'] = false;
    await faceapi.tf.ready()

err: Unhandled Promise Rejection: TypeError: null is not an object (evaluating 'e.isContextLost')

Remove the code related to the face API, and other functions related to "@ tensorflow/tfjs" are running normally

how fix?thanks

vladmandic commented 1 year ago

face-api does not have any reference to isContextLost, that is coming from somewhere else. and i see you're using window.ov8canvas - i have no experience using it (never seen it), but since isContextLost refers to WebGL context of the canvas, that is the first thing i would look at.