Angular & TensorFlow.js errors

Hi, it’s my first time using tensorflow.js with angular, I want to move my mouse on my hand movement, so I installed @tensorflow/tfjs and @tensorflow-models/handpose. I imported them in my module like so:

import * as tf from '@tensorflow/tfjs';
import * as handpose from '@tensorflow-models/handpose';

But it gives me errors, like 10x of this:

ERROR

node_modules/@tensorflow/tfjs-core/dist/hash_util.d.ts:2:49 - error TS2304: Cannot find name 'Long'.

2 export declare function hexToLong(hex: string): Long;
                                                  ~~~~


ERROR

node_modules/@tensorflow/tfjs-core/dist/hash_util.d.ts:3:69 - error TS2304: Cannot find name 'Long'.

3 export declare function fingerPrint64(s: Uint8Array, len?: number): Long;
                                                                      ~~~~


ERROR

node_modules/@tensorflow/tfjs-layers/dist/engine/training.d.ts:144:22 - error TS2420: Class 'LayersModel' incorrectly implements interface 'InferenceModel'.
  Types of property 'inputs' are incompatible.
    Type 'SymbolicTensor[]' is not assignable to type 'ModelTensorInfo[]'.
      Type 'SymbolicTensor' is not assignable to type 'ModelTensorInfo'.
        Types of property 'shape' are incompatible.
          Type 'Shape' is not assignable to type 'number[]'.
            Type 'number | null' is not assignable to type 'number'.
              Type 'null' is not assignable to type 'number'.

144 export declare class LayersModel extends Container implements tfc.InferenceModel {
                         ~~~~~~~~~~~


ERROR

node_modules/@tensorflow/tfjs-layers/dist/keras_format/topology_config.d.ts:17:5 - error TS2411: Property 'input_shape' of type 'Shape | undefined' is not assignable to 'string' index type 'PyJsonValue'.

17     input_shape?: Shape;
       ~~~~~~~~~~~


ERROR

node_modules/@tensorflow/tfjs-layers/dist/keras_format/topology_config.d.ts:18:5 - error TS2411: Property 'batch_input_shape' of type 'Shape | undefined' is not assignable to 'string' index type 'PyJsonValue'.

18     batch_input_shape?: Shape;

What can I do?

I am not really even sure how to use it in Angular, there’s not many resources on the internet, can someone provide me with documentation or useful info of how to use it and capture hand track please?

Thank you.

1 Like

Hi!. Same issue, with angular 15.
In compilerOptions add:
“skipDefaultLibCheck”: true,
“skipLibCheck”: true,

1 Like

Also just in case this is useful, Minko Gechev our DRE for Angular has been working with TensorFlow.js and gave a few talks etc showing how to integrate:

YouTube video:

Demo available here:

1 Like