diff --git a/.github/workflows/tests_full.yml b/.github/workflows/tests_full.yml index e550c88..0865876 100644 --- a/.github/workflows/tests_full.yml +++ b/.github/workflows/tests_full.yml @@ -73,7 +73,7 @@ jobs: matrix: os: [ windows-2019, ubuntu-18.04, macos-11 ] python-version: [ 3.6, 3.7, 3.8, 3.9 ] - pytorch-version: [1.8.0, 1.9.0, 1.10.0, 1.11.0, 1.12.0] + pytorch-version: [1.8.0, 1.9.0, 1.10.0, 1.11.0, 1.12.0, 1.13.0] exclude: - python-version: 3.6 pytorch-version: 1.11.0 diff --git a/example.py b/example.py index 6de0f36..98ba5b9 100644 --- a/example.py +++ b/example.py @@ -83,7 +83,6 @@ t_ = time.time() norm, H, E = tf_normalizer.normalize(I=t_to_transform, stains=True) print("tf runtime:", time.time() - t_) - plt.figure() plt.suptitle('tensorflow normalizer') plt.subplot(2, 2, 1) diff --git a/torchstain/torch/normalizers/macenko.py b/torchstain/torch/normalizers/macenko.py index 710b7e3..b04cd28 100644 --- a/torchstain/torch/normalizers/macenko.py +++ b/torchstain/torch/normalizers/macenko.py @@ -14,7 +14,8 @@ def __init__(self): [0.7201, 0.8012], [0.4062, 0.5581]]) self.maxCRef = torch.tensor([1.9705, 1.0308]) - + self.deprecated_torch = torch.__version__ < (1,9,0) + def __convert_rgb2od(self, I, Io, beta): I = I.permute(1, 2, 0) @@ -49,13 +50,16 @@ def __find_concentration(self, OD, HE): Y = OD.T # determine concentrations of the individual stains - return torch.lstsq(Y, HE)[0][:2] + if self.deprecated_torch: + return torch.lstsq(Y, HE)[0][:2] + + return torch.linalg.lstsq(HE, Y)[0] def __compute_matrices(self, I, Io, alpha, beta): OD, ODhat = self.__convert_rgb2od(I, Io=Io, beta=beta) # compute eigenvectors - _, eigvecs = torch.symeig(cov(ODhat.T), eigenvectors=True) + _, eigvecs = torch.linalg.eigh(cov(ODhat.T)) eigvecs = eigvecs[:, [1, 2]] HE = self.__find_HE(ODhat, eigvecs, alpha)