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

Scipy transformation #57

Merged
merged 7 commits into from
Jul 23, 2024

Conversation

SangbumChoi
Copy link
Collaborator

What does this PR do?

Fixes # (issue)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@SangbumChoi SangbumChoi marked this pull request as draft July 11, 2024 02:11
@SangbumChoi SangbumChoi marked this pull request as ready for review July 16, 2024 01:55
@SangbumChoi
Copy link
Collaborator Author

@NielsRogge It is good to go!

Copy link
Owner

@NielsRogge NielsRogge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, does this affect the logits check in the conversion script? If so, how much do they differ?

Feel free to update the conversion script

@SangbumChoi
Copy link
Collaborator Author

@NielsRogge Hi niels. I think your https://huggingface.co/datasets/nielsr/test-image/blob/main/vitpose_batch_data.pt is somehow outdated and gives

  File "/mnt/nas2/users/sbchoi/transformers/src/transformers/models/vitpose/convert_vitpose_to_hf.py", line 229, in convert_vitpose_checkpoint
    assert torch.allclose(pixel_values, original_pixel_values)

I need you to confirm or change this pt

@SangbumChoi SangbumChoi changed the title [WIP] need to check if the numpy function is same as cv Scipy transformation Jul 16, 2024
@NielsRogge
Copy link
Owner

NielsRogge commented Jul 16, 2024

Hmm so that should normally still work from my branch. Let me try:

(env) nielsrogge@Nielss-MacBook-Pro-2 transformers % python src/transformers/models/vitpose/convert_vitpose_to_hf.py
Shape of pixel values: torch.Size([2, 3, 256, 192])
Looks ok!

Yes confirmed. So the pixel values won't be the same anymore with this PR, so we can probably remove that check.

Could you tell how much they differ?

@SangbumChoi
Copy link
Collaborator Author

SangbumChoi commented Jul 17, 2024

@NielsRogge Two things to share

  1. the image size problem was my mistake I didn't put the output_shape value in the warp affine. Now it is fixed
  2. For the difference are like this

pass
torch.from_numpy(pose_results[0]["bbox"]).float()

  • tensor([412.8000, 157.6100, 464.8500, 294.6200])
  • torch.tensor([412.8, 157.61, 464.85, 294.62])

pass
torch.from_numpy(pose_results[1]["bbox"]).float()

  • tensor([384.4300, 172.2100, 398.5500, 206.9500])
  • torch.tensor([384.43, 172.21, 398.55, 206.95])

fail
torch.from_numpy(pose_results[1]["keypoints"][0, :3])

  • tensor([398.0621, 181.8478, 0.8792])
  • torch.tensor([398.07913, 181.82812, 0.88235235])

Copy link
Owner

@NielsRogge NielsRogge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! Great work

@NielsRogge NielsRogge merged commit c20462e into NielsRogge:add_vitpose_autobackbone Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants