Object-Detection Model Question.

165 views
Skip to first unread message

Jake Keenan

unread,
Mar 30, 2021, 7:47:16 AM3/30/21
to TensorFlow.js Discussion
Hi all,

I am new to TensorFlow.js and just learning out. I've followed numerous tutorials/blogs in trying to get my object detection model up and running in the browser, however, it has been unsuccessful so far. I have no problem training and exporting (in Google Colab) as well as converting the model for use in js. The problem looks like it may have something to do with my code (see link to GitHub repo below). It looks like every time (in the index.js file) I get to line 92 I am getting an "Uncaught (in promise) TypeError: Cannot read property 'backend' of undefined" error which I been stuck on for quite some time. From my perspective it looks like it has something to do with executeAsync() method. I feel that I am suppose to get a promise and that'll carry through to the next "then()" method, however, that's not the case. 
Also, I am not familiar with Glitch/CodePen at this stage and will look over them in the coming days, but thought I'd make a post anyways where I have made the code available at:

I've been following along with the below link, adjusting some of the code as I go:

Also used the following link to train/evaluate/export model:

P.s.: The model was trained on 100 images of apples. The model is by no means accurate as I just want to try and get the model working in the browser first, then I'll go back and optimize it. 

Many Thanks,
Jake

Jake Keenan

unread,
Mar 31, 2021, 8:41:29 AM3/31/21
to TensorFlow.js Discussion, Jake Keenan
My apologies I should have included some more information to make things a tad easier. 

If you git clone the project:
1) First do a "npm install"
2) Do "npm start react" and have it load in google chrome 
3) Then press the "Enable Webcam" button, I end up with the following error:
Screen Shot 2021-03-31 at 11.30.04 pm.png 
The process_input() function is providing a tensor (as you can see), however, when I pass that to executeAsync() that looks like where the problem is happening. I keep getting the TypeError: Cannot read property 'backend' .. which is where I am at. The other TypeError in regards to the length is because of rejected promise from the executeAsync(). 

I am executing this on macOS Big Sur v11.2.1 on a MacBook Pro (13-inch, 2020). 
I used tensorflowjs converter v3.3.0 to convert the saved model which was generated by Tensorflow v2.4.1.

Thanks,
Jake

Jake Keenan

unread,
Apr 1, 2021, 8:33:30 AM4/1/21
to TensorFlow.js Discussion, Jake Keenan
Hi all,

I managed to solve my problem. Problem was I was using the conversion wizard instead of the regular conversion script. I had to downgrade the version of tensorflowjs to v3.1.0 for the model to output predictions via the executeAsync() method. Also, I had to use v3.1.0 for the npm tfjs packages as well. Though, I didn't try out any other versions of tensorflowjs, this is what worked for me.

Thanks,
Jake

Ping Yu

unread,
Apr 1, 2021, 12:34:31 PM4/1/21
to TensorFlow.js Discussion, keena...@gmail.com
Hi Jake

Thank you for reporting this issue, we have identified the bug causing pre-mature tensor disposal for TensorList ops.
FYI, there is a fix PR submitted.

Thanks

Ping

Reply all
Reply to author
Forward
0 new messages