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

PoseNet models don't accept batch sizes greater than 1. #1864

Closed
oveddan opened this issue Aug 19, 2019 · 5 comments
Closed

PoseNet models don't accept batch sizes greater than 1. #1864

oveddan opened this issue Aug 19, 2019 · 5 comments
Assignees
Labels
type:bug Something isn't working

Comments

@oveddan
Copy link
Contributor

oveddan commented Aug 19, 2019

I'm writing some custom code that is to feed a batch of images into the PoseNet models for inference; in my case its a series of frames from long videos. I would eventually open a PR that supports this functionality.

However, when feeding a batch size of greater than one to both the MobileNet and ResNet models, you get an error:

Error: The shape of dict['sub_2'] provided in model.execute(dict) must be [1,-1,-1,3], but was [5,537,953,3]

A way to simply reproduce the error source is:

  const url =
      'https://storage.googleapis.com/tfjs-models/savedmodel/posenet/resnet50/quant1/model-stride16.json'
  const graphModel = await tf.loadGraphModel(url);

  const inputTensor = tf.zeros([5, 100, 100, 3]);

  const result = graphModel.predict(inputTensor);

The above code results in an error:

UnhandledPromiseRejectionWarning: Error: The shape of dict['sub_2'] provided in model.execute(dict) must be [1,-1,-1,3], but was [5,100,100,3]

The same thing occurs for other model urls.

CC @tylerzhu-github

caisq added a commit to caisq/tfjs-1 that referenced this issue Aug 20, 2019
tensorflow#1864)

FEATURE

- This is the first PR for adding support for user-defined metadata in model artifacts. Design doc has been circulated and discussed.
- Add the field `userDefinedMetadata` to `ModelArtifacts` and `ModelJSON`.
- Deprecate the old API of `tf.io.fromMemory()` which consisted of multiple arguments. The arguments are consolidated into on in the new API.
- Add unit tests.

Towards tensorflow#1596
@rthadur rthadur added the type:bug Something isn't working label Aug 20, 2019
@rthadur
Copy link
Contributor

rthadur commented Aug 30, 2019

CC @tylerzhu-github gentle ping to check this error.

@tylerzhu-github
Copy link

Thanks for the reminder!
Yes that will require exporting a model that support batch size > 1.
Will handle that in the next release, timeline would be end of next quarter.

@oveddan
Copy link
Contributor Author

oveddan commented Sep 3, 2019

@tylerzhu-github thanks! Does this require re-training the model or just a modification to how the model is exported?

@rthadur
Copy link
Contributor

rthadur commented May 13, 2022

Will be closing this issue as we will be using latest body segmentation model for same purpose.
Please check latest body segmentation model for latest bodypix model demo https://github.com/tensorflow/tfjs-models/tree/master/body-segmentation

@rthadur rthadur closed this as completed May 13, 2022
@google-ml-butler
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants