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

Show tensors shaped [H, W, 1, 1] as images #1871

Closed
emilk opened this issue Apr 17, 2023 · 2 comments · Fixed by #2075
Closed

Show tensors shaped [H, W, 1, 1] as images #1871

emilk opened this issue Apr 17, 2023 · 2 comments · Fixed by #2075
Assignees
Labels
😤 annoying Something in the UI / SDK is annoying to use enhancement New feature or request good first issue Good for newcomers 🏎️ Quick Issue Can be fixed in a few hours or less

Comments

@emilk
Copy link
Member

emilk commented Apr 17, 2023

Mentioned here and elsewhere:

It is fairly common to store a single image in a [H, W, 1, 1] or [H, W, 3, 1] tensor.

However, currently Rerun only shows [H, W, 1|3|4] tensors as images, despite the trailing unit-dimension beeing an noop.

This should be fairly easy to handle by ignoring trailing unit-dimensions in:

  • Tensor::image_height_width_channels
  • Tensor::is_shaped_like_an_image
  • Tensor::is_vector

Preferably they would just use the same function, fn shape_short(&self) -> &[TensorDimension]

@emilk emilk added enhancement New feature or request 👀 needs triage This issue needs to be triaged by the Rerun team good first issue Good for newcomers 🏎️ Quick Issue Can be fixed in a few hours or less 😤 annoying Something in the UI / SDK is annoying to use and removed 👀 needs triage This issue needs to be triaged by the Rerun team labels Apr 17, 2023
@tauseefmohammed2
Copy link

Hi!
I would love to contribute to the repo. I saw that the issue is labelled "first time", which is perfect for me as I am new to this project and eager to get started. Could you please assign this issue to me?

If I am not wrong, this is a straightforward implementation change that can be made. The fucntion can simply check if the last dimension of the tensor is a unit-dimension, and if so, remove it before displaying the image.

@Wumpf
Copy link
Member

Wumpf commented Apr 18, 2023

@tauseefmohammed2 sure go ahead! We actually rarely use the assign feature 😄 , but this way at least nobody else starts working on it redundantly :)
Yeah I think you're right should be as straight forward as you say - returning a subslice of the dimension that ignores trailing unit dimensions. Tbh not sure why @emilk calls this sort (:

EDIT: I misread short as sort. short makes a lot of sense

@Wumpf Wumpf assigned Wumpf and unassigned tauseefmohammed2 May 9, 2023
Wumpf added a commit that referenced this issue May 9, 2023
… an image.

Fixes #1871
Quite a bit of nuance to support single channel 1x1 images & line-like images.
Wumpf added a commit that referenced this issue May 10, 2023
* Ignore trailing tensor dimension when determining whether a tensor is an image.
Fixes #1871
Quite a bit of nuance to support single channel 1x1 images & line-like images.

* fix image preview for images other than M x N x C and M x N

* comment fix

* better shape_short comment

* handle empty tensors

* is_shaped_like_an_image is now defined via image_height_width_channels, improve comment on both

* any Nx1x... image now now treated as image

* rename to get_with_image_coords, make it more restrictive

* tensor_to_gpu height_width_depth utility uses now tensor.image_height_width_channels

* change behavior of is_vector
jprochazk pushed a commit that referenced this issue May 11, 2023
* Ignore trailing tensor dimension when determining whether a tensor is an image.
Fixes #1871
Quite a bit of nuance to support single channel 1x1 images & line-like images.

* fix image preview for images other than M x N x C and M x N

* comment fix

* better shape_short comment

* handle empty tensors

* is_shaped_like_an_image is now defined via image_height_width_channels, improve comment on both

* any Nx1x... image now now treated as image

* rename to get_with_image_coords, make it more restrictive

* tensor_to_gpu height_width_depth utility uses now tensor.image_height_width_channels

* change behavior of is_vector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
😤 annoying Something in the UI / SDK is annoying to use enhancement New feature or request good first issue Good for newcomers 🏎️ Quick Issue Can be fixed in a few hours or less
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants