tfjs icon indicating copy to clipboard operation
tfjs copied to clipboard

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

Open pravastacaraka opened this issue 5 years ago • 16 comments

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)

pravastacaraka avatar Feb 04 '21 13:02 pravastacaraka

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

rthadur avatar Feb 04 '21 17:02 rthadur

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

pravastacaraka avatar Feb 06 '21 10:02 pravastacaraka

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

google-ml-butler[bot] avatar Feb 06 '21 10:02 google-ml-butler[bot]

What did you do? i have the same problem.

dewball345 avatar Jun 04 '21 16:06 dewball345

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

pravastacaraka avatar Jun 06 '21 04:06 pravastacaraka

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 avatar Jun 06 '21 05:06 dewball345

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 avatar Jun 06 '21 05:06 dewball345

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 avatar Jun 10 '21 22:06 dewball345

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

pravastacaraka avatar Jun 11 '21 12:06 pravastacaraka

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 avatar Jun 11 '21 23:06 dewball345

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 avatar Jun 17 '21 04:06 dewball345

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

pravastacaraka avatar Jun 17 '21 04:06 pravastacaraka

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

dewball345 avatar Jun 22 '21 20:06 dewball345

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.

nimishdesai1989 avatar Aug 25 '21 11:08 nimishdesai1989

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

dewball345 avatar Aug 25 '21 16:08 dewball345

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 ?

nimishdesai1989 avatar Aug 26 '21 11:08 nimishdesai1989