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
824 stars 149 forks source link

createTensorFromGPUData error when testing ? #152

Closed ghost closed 1 year ago

ghost commented 1 year ago

Issue Description

(asked in Tensorflow js as well, but it will take long to have any feedback.)

I wonder if anyone else fall into this problem, basically I can run the code with ts-node and also in the browser (I am doing a code that will run in both envs.)

But when testing with ts-jest, I get this error (running the "test detectors" test):

 FAIL  src/__tests__/test.ts (6.393 s)
  test detectors
    ✕ should return a detection object (86 ms)

    'createTensorFromGPUData' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen

      at notYetImplemented (tfjs-core/src/backends/backend.ts:159:9)
      at NodeJSKernelBackend.Object.<anonymous>.KernelBackend.createTensorFromGPUData (tfjs-core/src/backends/backend.ts:139:12)
      at makeTensor (tfjs-core/src/ops/tensor_ops_util.ts:44:27)
      at tensor (tfjs-core/src/ops/tensor.ts:196:10)
      at decodeWeights (tfjs-core/src/io/io_utils.ts:224:19)
      at tfjs-core/src/io/weights_loader.ts:236:13
          at Array.forEach (<anonymous>)
      at tfjs-core/src/io/weights_loader.ts:231:22
          at Array.forEach (<anonymous>)
      at Object.<anonymous> (tfjs-core/src/io/weights_loader.ts:212:25)
      at step (node_modules/tslib/tslib.es6.js:102:23)
      at Object.next (node_modules/tslib/tslib.es6.js:83:53)
      at fulfilled (node_modules/tslib/tslib.es6.js:73:58)

Steps to Reproduce

I can not provide one, but I reduced the error to a single line, this line.

Expected Behavior

It just run the tests at least (not saying it is face-api fault !)

Environment

vladmandic commented 1 year ago

big question is why is ts-jest testing internal functions within @tensorflow/tfjs ?!?! and the function it complains about createTensorFromGPUData is brand new and pretty much experimental, it does not have full support or test coverage.

sorry, nothing i can do about this. in reality, ts-jest scope should be limited - not to dig into pre-compiled ibraries - they are compiled for a reason.

ghost commented 1 year ago

Cant research further now but I did this:

 -add the line import ts from "@tensorflow/ts-node" (didn't solve but I kept it)
- add vitest (didn't solve but I kept it)
- `npm rebuild` or remove `rm -rf node_modules` and reinstall and it runs the tests fine.

This was the error in vitest that directed me to the last step: https://stackoverflow.com/questions/28486891/uncaught-error-module-did-not-self-register

I asked here as well https://github.com/tensorflow/tfjs/issues/7285

Works fine now. Thanks for reaching back

vladmandic commented 1 year ago

strange, but seems like there was a partially corrupt installation of @tensorflow/tfjs-node, glad you found it.