tfjs-models/coco-ssd Uncaught (in promise) TypeError: Cannot read property 'read' of undefined with script tag example

Created on 6 Aug 2020  路  14Comments  路  Source: tensorflow/tfjs

To get help from the community, we encourage using Stack Overflow and the tensorflow.js tag.

TensorFlow.js version

@tensorflow/tfjs@latest

Browser version

Chrome

Describe the problem or feature request

I used the example provided for the model coco-ssd with script tag but I get the following error :
tfjs:17 Uncaught (in promise) TypeError: Cannot read property 'read' of undefined
at tfjs:17
at u (tfjs:17)
at Generator._invoke (tfjs:17)
at Generator.forEach.t. [as next] (tfjs:17)
at Wm (tfjs:17)
at o (tfjs:17)
at tfjs:17
at new Promise ()
at tfjs:17
at tfjs:17

Code to reproduce the bug / link to feature request

models stalled awaiting response bug

Most helpful comment

Choosing TFJS 2.0.0 works for me

All 14 comments

@htmbennis this will be fixed in upcoming 2.2 release

I'm having this problem too. Is there any workaround or version that works?

You can lock the TFJS version to 2.0.1

Hi - same problem, tried locking to 2.0.1 but getting an error - Uncaught (in promise) Error: The dtype of dict['image_tensor'] provided in model.execute(dict) must be int32, but was float32. I'm using video, it won't let me cast it. Any tips to get round this?

I'm a newbie so any advice is greatly appreciated. I'm using both TF object and 3d face landmark model together. No issues until this week when @2.0.3 objects stopped working and giving the error uncaught - read etc.

Choosing TFJS 2.0.0 works for me

Thanks @aeggarut, tried that but still getting the same errors.

`const videoFeed = document.querySelector('stream');
const videoElem = document.querySelector('#videoElement');

let model = null;
let videoStartTime;
//starts video stream
let video = document.querySelector("#videoElement");
if (navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia({
video: true
}).then(function(stream) {
video.srcObject = stream;
setInterval(function() {
objects();
}, 4000);
})
.catch(function(err0r) {
console.log("Video stream error", err0r);
});
}
//function to check and predict if there are foregin objects in stream - phones, books, TODO headphones

async function objects() {
cocoSsd.load().then(model => {
// detect objects in the image.

        model.detect(video).then(predictions => { 

        console.log('Predictions: ', predictions);
    });
});

} `

I pulled the set up from the docs and a few different tutorials for set up. It worked perfectly but now I'm totally lost as to why it won't work anymore. Am I missing something obvious from my set up code? Scripts added in >

`!--tensorflow -->




<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>

`

Slowly going insane trying to work it out

@Laurenceldp you can checkout my github repo for reference, it also has a Glitch app. feel free to test it and/or remix it at https://tfjswebcam.glitch.me.

@kalmufti Thanks so much for this, really helpful!

@kalmufti Thanks so much for this, really helpful!

Glad it helped you :) I would really appreciate it if you give my repo a star :star: I intend to keep it up to date, also add more models like PosNet, etc.

As a temp solution, you can use older versions of tfjs

This are the scripts that made it work for me

<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/[email protected]/dist/coco-ssd.min.js"></script>

Not just the script, facing the same with the npm module too..
Temporarily TFJS 2.0.0 worked fine.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 dyas if no further activity occurs. Thank you.

Closing as stale. Please @mention us if this needs more attention.

Are you satisfied with the resolution of your issue?
Yes
No

Was this page helpful?
0 / 5 - 0 ratings