machine-learningtensorflow.jsglitch-framework

TensorflowJS TFJS error: The dtype of dict


Had tried to run https://glitch.com/~tar-understood-exoplanet and the model would fail to load and I wouldn't be able to use enable the webcam.

Anyone had the same issue?

While the program is running, in the console I get the following:

tfjs:2 Uncaught (in promise) Error: The dtype of dict['image_tensor'] provided in model.execute(dict) must be int32, but was float32
    at Object.b [as assert] (tfjs:2)
    at tfjs:2
    at Array.forEach (<anonymous>)
    at t.checkInputShapeAndType (tfjs:2)
    at t.<anonymous> (tfjs:2)
    at tfjs:2
    at Object.next (tfjs:2)
    at tfjs:2
    at new Promise (<anonymous>)
    at Zv (tfjs:2)

I have a Macbook Pro and some other people on their Windows also had some issues running the model. We also tried it on different browsers, Safari and Chrome.

SUCCESS! after switching to coco-ssd 2.0.2:

I added the version 2.0.2 in line 62 as follows:

<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/coco-ssd@2.0.2"></script>

Solution

  • This is caused by the warmup run of coco-ssd that uses tf.zeros tensor. The default dtype for tf.zeros is 'float' in the recent release of TFJS. I have put out a new version with fixes. It should work if you use the latest version of coco-ssd (2.0.2) in the glitch example (index.html) as following.

        <!-- Load the coco-ssd model to use to recognize things in images -->
        <script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/coco-ssd@2.0.2"></script>