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

[Fix] Dimension Mismatch in 5D Tensor Permute Operation in visualization_hook.py #2697

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kim-jeonghyun
Copy link

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily got feedback.
If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

The following code in _draw_datasample function of visualization_hook.py attempts to permute a video tensor, which leads to a dimension mismatch error.

video = video.permute(1, 2, 3, 0).numpy().astype('uint8')

Executing this line throws the following error message:

RuntimeError: permute(sparse_coo): number of dimensions in the tensor input does not match the length of the desired ordering of dimensions i.e. input.dim() = 5 is not equal to len(dims) = 4

Modification

Modified the video tensor manipulation logic to handle each video individually. This avoids the dimension mismatch issue.

  • Iterated through each video.
  • Used 'permute' and 'astype' to rearrange and typecast each frame.
# Code snippet showing the changes
for i in range(video.shape[0]):
    single_video = video[i].permute(1, 2, 3, 0).numpy().astype('uint8')
    # rest of the code

BC-breaking (Optional)

Does the modification introduces changes that break the back-compatibility of this repo?
No

Use cases (Optional)

If this PR introduces a new feature, it is better to list some use cases here, and update the documentation.
No

Checklist

  1. Pre-commit or other linting tools should be used to fix the potential lint issues.
  2. The modification should be covered by complete unit tests. If not, please add more unit tests to ensure the correctness.
  3. If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDet or MMCls.
  4. The documentation should be modified accordingly, like docstring or example tutorials.

@CLAassistant
Copy link

CLAassistant commented Oct 3, 2023

CLA assistant check
All committers have signed the CLA.

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.

None yet

3 participants