Integrating TensorFlow.js with PlayCanvas?

Has anyone managed to get tfjs working with playcanvas? I’ve been trying and I get the following error:

Source map error: Error: request failed with status 404
Resource URL: https://cdn.jsdelivr.net/npm/@tensorflow/tfjs
Source Map URL: tf.min.js.map

I’ve just added the js files from the coco-ssd object detector demo (https://github.com/tensorflow/tfjs-models/tree/master/coco-ssd).

I think I can eventually get it to work but I wanted to check if anyone else has already done this.

Is this in the editor or in an engine only project?

If editor only, can you share the project you are having trouble with please?

Engine only.

Want to use object detection neural network output as input for a game mechanic.

A 404 result shouldn’t be an engine issue :confused:

Have you tried to open that file directly in the browser? https://cdn.jsdelivr.net/npm/@tensorflow/tfjs

Its actually working now…
It was probably some cache issue on my end…

I havn’t used anything like playcanvas before (I’ve worked predominantly with UE and Unity) so I wasn’t sure where the problem was.

For anyone else looking to do the same thing. All you need to do is add the tensorflow.js scripts in the external scripts section of the settings. You can then use the library as you normally would, just avoid using await when in the update function of a component as it can cause things to hang.

Oh, you are using the Editor now?

I think I misunderstood your first question. When you said in editor I thought you meant trying to run tensorflow in the editor.