Skip to content

Commit 602b5b1

Browse files
remove ssim from tests
1 parent 13a338c commit 602b5b1

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

tests/test_tf.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import torchstain
44
import torchstain.tf
55
import tensorflow as tf
6-
import time
7-
from skimage.metrics import structural_similarity as ssim
86
import numpy as np
97

108
def test_cov():
@@ -44,11 +42,11 @@ def test_macenko_tf():
4442
result_tf, _, _ = tf_normalizer.normalize(I=t_to_transform, stains=True)
4543

4644
# convert to numpy and set dtype
47-
result_numpy = result_numpy.astype("float32")
48-
result_tf = result_tf.numpy().astype("float32")
45+
result_numpy = result_numpy.astype("float32") / 255.
46+
result_tf = result_tf.numpy().astype("float32") / 255.
4947

5048
# assess whether the normalized images are identical across backends
51-
np.testing.assert_almost_equal(ssim(result_numpy.flatten(), result_tf.flatten()), 1.0, decimal=4, verbose=True)
49+
np.testing.assert_almost_equal(result_numpy.flatten(), result_tf.flatten(), decimal=2, verbose=True)
5250

5351
def test_reinhard_tf():
5452
size = 1024
@@ -72,8 +70,8 @@ def test_reinhard_tf():
7270
result_tf = tf_normalizer.normalize(I=t_to_transform)
7371

7472
# convert to numpy and set dtype
75-
result_numpy = result_numpy.astype("float32")
76-
result_tf = result_tf.numpy().astype("float32")
73+
result_numpy = result_numpy.astype("float32") / 255.
74+
result_tf = result_tf.numpy().astype("float32") / 255.
7775

7876
# assess whether the normalized images are identical across backends
79-
np.testing.assert_almost_equal(ssim(result_numpy.flatten(), result_tf.flatten()), 1.0, decimal=4, verbose=True)
77+
np.testing.assert_almost_equal(result_numpy.flatten(), result_tf.flatten(), decimal=2, verbose=True)

tests/test_torch.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
import torchstain.torch
55
import torch
66
import torchvision
7-
import time
87
import numpy as np
98
from torchvision import transforms
10-
from skimage.metrics import structural_similarity as ssim
9+
1110

1211
def setup_function(fn):
1312
print("torch version:", torch.__version__, "torchvision version:", torchvision.__version__)
@@ -52,11 +51,11 @@ def test_macenko_torch():
5251
result_torch, _, _ = torch_normalizer.normalize(I=t_to_transform, stains=True)
5352

5453
# convert to numpy and set dtype
55-
result_numpy = result_numpy.astype("float32")
56-
result_torch = result_torch.numpy().astype("float32")
54+
result_numpy = result_numpy.astype("float32") / 255.
55+
result_torch = result_torch.numpy().astype("float32") / 255.
5756

5857
# assess whether the normalized images are identical across backends
59-
np.testing.assert_almost_equal(ssim(result_numpy.flatten(), result_torch.flatten()), 1.0, decimal=4, verbose=True)
58+
np.testing.assert_almost_equal(result_numpy.flatten(), result_torch.flatten(), decimal=2, verbose=True)
6059

6160
def test_reinhard_torch():
6261
size = 1024
@@ -83,8 +82,9 @@ def test_reinhard_torch():
8382
result_torch = torch_normalizer.normalize(I=t_to_transform)
8483

8584
# convert to numpy and set dtype
86-
result_numpy = result_numpy.astype("float32")
87-
result_torch = result_torch.numpy().astype("float32")
85+
result_numpy = result_numpy.astype("float32") / 255.
86+
result_torch = result_torch.numpy().astype("float32") / 255.
8887

88+
8989
# assess whether the normalized images are identical across backends
90-
np.testing.assert_almost_equal(ssim(result_numpy.flatten(), result_torch.flatten()), 1.0, decimal=4, verbose=True)
90+
np.testing.assert_almost_equal(result_numpy.flatten(), result_torch.flatten(), decimal=2, verbose=True)

0 commit comments

Comments
 (0)