Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught (in promise) TypeError: Cannot read property 'name' of undefined #4637

Closed
pravastacaraka opened this issue Feb 4, 2021 · 16 comments
Assignees

Comments

@pravastacaraka
Copy link

pravastacaraka commented Feb 4, 2021

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 ()
at GraphExecutor.executeFunctionAsync (graph_executor.js:306)
at Module.executeOp (control_executor.js:31)
at async Promise.all (:3000/index 0)
at async GraphExecutor.executeWithControlFlow (graph_executor.js:351)
at async GraphExecutor._executeAsync (graph_executor.js:285)
at async GraphModel.executeAsync (graph_model.js:316)

@rthadur
Copy link
Contributor

rthadur commented Feb 4, 2021

@pravastacaraka can you please share minimal code to reproduce the error , you can create a repo or use codepen. Thank you

@rthadur rthadur self-assigned this Feb 4, 2021
@pravastacaraka
Copy link
Author

Sorry for the late response, I've fixed this problem

@google-ml-butler
Copy link

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

@dewball345
Copy link

What did you do? i have the same problem.

@pravastacaraka
Copy link
Author

@dewball345 Unfortunately there is no way to fix this yet. As we know on PR ultralytics/yolov5#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.

@dewball345
Copy link

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?

@dewball345
Copy link

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!

@dewball345
Copy link

dewball345 commented Jun 10, 2021

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/.

@pravastacaraka
Copy link
Author

@dewball345 Have you finished the algorithm of non-max suppression?

@dewball345
Copy link

dewball345 commented Jun 11, 2021 via email

@dewball345
Copy link

dewball345 commented Jun 17, 2021 via email

@pravastacaraka
Copy link
Author

@dewball345 I really appreciate it. Awaited the good news!

@dewball345
Copy link

@pravastacaraka Okay, i implemented the nms as well as some pre/post processing, and you can view it here

@nimishdesai1989
Copy link

hello @pravastacaraka : i am still getting this error on using the ssd_mobilenet v2 model.

22399021-BB51-4439-A318-AA0C18A7CE58

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.

@dewball345
Copy link

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

@nimishdesai1989
Copy link

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants