EIDOSLAB / EIDOSLAB/torchstain
Torch backend returns tensor of different shape and data type then input
- Dominant language
- Python
- Stars
- 191
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.