EIDOSLAB / EIDOSLAB/torchstain

Crash when calling MacenkoNormalizer.fit with tensorflow backend

Open
#37 12 comments 1 reaction 1 assignee Claimed by @andreped View on GitHub
documentation good first issue
Dominant language
Python
Stars
191
Forks
30
PR merge metrics
No merged PRs in 30d

Description

Hi,
I am sorry if my question is trivial but I have trouble using this package with the tensorflow backend.
Using torchstain 1.2.0, I have no problem performing a Macenko normalization with numpy. But as I try with tensorflow, it crashes using normalizer.fit

```
target_path = '/XXX.jpg'
target = cv2.cvtColor(cv2.imread(target_path), cv2.COLOR_BGR2RGB)
tf_normalizer = torchstain.normalizers.MacenkoNormalizer(backend='tensorflow')
```

The only thing that I am doing differently from the provided example is the tensor conversion of the numpy array.
That is, I am not doing this

```
T = transforms.Compose([
transforms.ToTensor(),
transforms.Lambda(lambda x: x*255)
])
```

But rather tried this to match the transformation:

```
target = tf.constant(target, dtype=tf.float32) #convert to tensor
target = tf.transpose(target, perm=[2, 0, 1]) #channel first

tf_normalizer.fit(target)
```

Is this why it crashes ? Is there a way to run this without using torchvision.transforms/on a pure TF basis?

I am using Tensorflow_2.10.0 and have installed torchstain using pip install torchstain[tf].
I currently do not use nor have installed torchvision in my TF environment.

Thank you for your advice

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.