Uncaught (in promise) TypeError: Cannot read property 'name' of undefined
Please make sure that this is a build/installation issue. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:build_template
System information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10 Education 20H2 64-bit
- TensorFlow.js installed from (npm or script link): npm
- TensorFlow.js version: 3.0.0
- CUDA/cuDNN version: Not using
Describe the problem Previously I had a trained model from YOLOv5. Then I wanted to try running it in the browser, so I converted it to the tfjs model. However, I have a problem when inference.
Provide the exact sequence of commands/steps that you executed before running into the problem I call the element of an image, then I change it to tensor4d then I predict, but this problem always arises: "Uncaught (in promise) TypeError: Cannot read property 'name' of undefined"
Any other info/logs
Uncaught (in promise) TypeError: Cannot read property 'name' of undefined
at graph_executor.js:307
at Array.reduce (
@pravastacaraka can you please share minimal code to reproduce the error , you can create a repo or use codepen. Thank you
Sorry for the late response, I've fixed this problem
What did you do? i have the same problem.
@dewball345 Unfortunately there is no way to fix this yet. As we know on PR https://github.com/ultralytics/yolov5/pull/1127 using ops tf.image.combined_non_max_suppression() which apparently is not supported by TensorFlow.js. So we have to convert YOLOv5 model *.pt to TensorFlow.js model without using --tf-nms argument and apply NMS manually in our website program.
Sorry for the late response, I've fixed this problem
Okay, so why did you put this then? also, I converted from pytorch to onnx to tensorflow .pb then to tensorflowjs with tensorflow_converter. Was there anything else that you did?
I will try later using this PR as well, though I think there may be something wrong with my input. Can i see your tensorflow.js inference code? thanks!
Okay, so i was able to conduct inference in tensorflow.js and am currently working on a non-max suppression algorithm. What i did previously is that I converted pytorch -> onnx -> tensorflow saved model -> tensorflow.js. In the last step, there may have been some kind of conversion error. I suggest you use @zldrobit's tensorflow branch of the ultralytics' yolov5 repo. You can find the link at https://github.com/zldrobit/yolov5/.
@dewball345 Have you finished the algorithm of non-max suppression?
No, not yet. You know, it's. Actually quite simple(just turn the non max suppression function in utils.general to js)
On Fri, Jun 11, 2021, 5:48 AM Pravasta Caraka @.***> wrote:
@dewball345 https://github.com/dewball345 Have you finished the algorithm of non-max suppression?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/tfjs/issues/4637#issuecomment-859557452, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHGJKVHNEHCPPGNS7WGSJB3TSIAZLANCNFSM4XCZ3W4A .
Okay, you can expect it soon; i'm probably going to make a repo with it
On Fri, Jun 11, 2021 at 4:20 PM Abhiraam Eranti @.***> wrote:
No, not yet. You know, it's. Actually quite simple(just turn the non max suppression function in utils.general to js)
On Fri, Jun 11, 2021, 5:48 AM Pravasta Caraka @.***> wrote:
@dewball345 https://github.com/dewball345 Have you finished the algorithm of non-max suppression?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/tfjs/issues/4637#issuecomment-859557452, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHGJKVHNEHCPPGNS7WGSJB3TSIAZLANCNFSM4XCZ3W4A .
@dewball345 I really appreciate it. Awaited the good news!
@pravastacaraka Okay, i implemented the nms as well as some pre/post processing, and you can view it here
hello @pravastacaraka : i am still getting this error on using the ssd_mobilenet v2 model.

I used the repo and training from tensorflow blog below. https://blog.tensorflow.org/2021/01/custom-object-detection-in-browser.html
Is there any help you all can offer. I am bit new to this object detection and I think I am stuck.
This shouldnt be an error with the model? Looks like you were using some template and forgot to change the number of classes to your amount... I'm guessing the index i was greater than the number of classes that you had in your model, but I'm not sure
Hi @dewball345 : I will recheck this but I am quite sure I had changed the number of classes to 6 which is what my required number of classes are supposed to be. However, the prediction is returning a number like "1190" which is thus obviously outside the expected classes json defined earlier in the program. that is also why the model is not able to get the name for class 1190 which is not in my master definition. but the problem is, this same model is able to detect the objects correctly on server using python. the converted model to tensorflowjs is where the problem is. Would you have any idea on why this can be ?