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

Torch backend returns tensor of different shape and data type then input #56

Open
biagio-lunit opened this issue Oct 20, 2024 · 0 comments

Comments

@biagio-lunit
Copy link

First of all, thank you for implementing this library, it is useful to have different stain normalization algorithms with a simple pip install.

Describe the bug
Macenko normalizer changes the image shape and dtype after normalization,
which requires additional steps in the dataloader which is unexpected and unnecessary.

To Reproduce

H, W, C = 100, 100, 3
target = torch.rand(C, H, W).to(torch.float32)
query = torch.rand(C, H, W).to(torch.float32)
normalizer = torchstain.normalizers.MacenkoNormalizer(backend="torch")
normalizer.fit(target)
query_norm = normalizer.normalize(query)[0]
assert query_norm.shape == query.shape, f'{query_norm.shape} == {query.shape}'
assert query_norm.dtype == query.dtype, f'{query_norm.dtype} == {query.dtype}'

the output is

AssertionError: torch.Size([100, 100, 3]) == torch.Size([3, 100, 100])
AssertionError: torch.int32 == torch.float32

Expected behavior
Image before and after normalization should be the same shape and type.

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

No branches or pull requests

1 participant