-
Notifications
You must be signed in to change notification settings - Fork 541
Optim-wip: Add better colorspace support, image grids, & user agent to ImageTensor #839
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
Optim-wip: Add better colorspace support, image grids, & user agent to ImageTensor #839
Conversation
* Added color space support to `save_tensor_as_image` & `ImageTensor.export`. * Added image grid creation support to `ImageTensor.export` , `ImageTensor.show` , `show` & `save_tensor_as_image` via a new `make_grid_image` function. * Added user agent to `ImageTensor.open` as sites like Wikipedia require user agents.
tests/optim/utils/image/common.py
Outdated
] | ||
] | ||
) | ||
self.assertEqual(list(expected_output.shape), [1, 1, 7, 10]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The transformation doesn't seem very clear. Do you mind adding more details how 6 x 1 x 2 x 2 transforms into 1 x 1 x 7 x 10 ? nrow
argument looks a bit unclear to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Border has a size of 1, and we are using 3 in a row:
total_w = (n_row * border) + border + (n_row * tensor_dim_w)
total_h = (n_column * border) + border + (n_column * tensor_dim_h)
(3 * 1) + 1+ (3 * 2) = 10
(2 * 1) + 1+ (2 * 2) = 7
The n_column
value is calculated based on the given nrow value and how tensors in the list / batch dimension there are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the above comment to the tests!
@ProGamerGov, where is this "make image grid" functionality used now ? Are we using it in activation atlas ? |
@NarineK The functionality is currently used for when visualizations are displayed to the user, and when they wish to save them as images. Previously users would might have to scroll a lot horizontally when viewing multiple visualizations stacked across the batch dimension, or the image displayed would too small to be useful. The activation atlas grids are different as not every cell has a visualization, and the atlas grid is defined based on the dimensionality reduced point graph. In this PR for displaying images we simply specify how many images per row and if we want any padding. |
@NarineK Currently this is what happens for example if a user uses the show function to display 12 visualizations stacked across the batch dimension:
With this PR, the same user could specify
A similar thing happens with image saving, and this PR lets users fix that as well by specifying what they want for |
Thank you for the explanation, @ProGamerGov ! In that case it's would be better to call it The documentation says:
At this point it looks to me number of columns 4 and rows 3 |
@NarineK Ah, I see the problem! I've changed |
It's no longer required now that the images_per_row variable was renamed.
save_tensor_as_image
&ImageTensor.export
.ImageTensor.export
,ImageTensor.show
,show
&save_tensor_as_image
via a newmake_grid_image
function. This makes it easier for users to view multiple images stacked across the batch dimension without having to scroll horizontally.ImageTensor.open
as sites like Wikipedia require user agents.