Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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/[email protected]"></script>
like image 996
Claire Kim Avatar asked Apr 04 '20 23:04

Claire Kim


2 Answers

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/[email protected]"></script>
like image 136
Ping Yu Avatar answered Oct 01 '22 04:10

Ping Yu


Same error here, just occured since Friday night (04/03/2020) TFModel works well in past few weeks.

like image 32
RainCast Avatar answered Oct 01 '22 04:10

RainCast