Skip to content

Commit 987861a

Browse files
authored
Merge branch 'develop' into add-slide-data
2 parents 6e0638a + ce25587 commit 987861a

File tree

10 files changed

+23
-16
lines changed

10 files changed

+23
-16
lines changed

.github/workflows/conda-env-create.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
runs-on: ${{ matrix.os }}
3434
timeout-minutes: 20
3535
steps:
36-
- uses: actions/checkout@v2
36+
- uses: actions/checkout@v4
3737
- name: Copy requirements files
3838
shell: bash
3939
run: |
@@ -48,3 +48,4 @@ jobs:
4848
run: |
4949
micromamba info
5050
micromamba list
51+
python -c "import torch, numpy; print(torch.__version__, numpy.__version__)"

.github/workflows/mypy-type-check.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
sudo apt update
3434
sudo apt-get install -y libopenslide-dev openslide-tools libopenjp2-7 libopenjp2-tools
3535
python -m pip install --upgrade pip
36+
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
3637
pip install -r requirements/requirements_dev.txt
3738
3839
- name: Perform type checking

.github/workflows/pip-install.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ jobs:
5555
- name: OpenJPEG Version Information
5656
continue-on-error: true # This -h option has exit code 1 for some reason
5757
run: opj_dump -h
58+
- name: Install CPU-only PyTorch
59+
run: python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
5860
- name: pip Install From GitHub Repo on Linux and macOS
5961
if: runner.os != 'Windows'
6062
run: python -m pip install git+https://github.com/TissueImageAnalytics/tiatoolbox@${GITHUB_SHA}

.github/workflows/python-package.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jobs:
3030
sudo apt update
3131
sudo apt-get install -y libopenjp2-7 libopenjp2-tools
3232
python -m pip install --upgrade pip
33-
python -m pip install ruff==0.14.3 pytest pytest-cov pytest-runner
33+
python -m pip install ruff==0.14.7 pytest pytest-cov pytest-runner
34+
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
3435
pip install -r requirements/requirements.txt
3536
- name: Cache tiatoolbox static assets
3637
uses: actions/cache@v4
@@ -107,6 +108,7 @@ jobs:
107108
run: |
108109
sudo apt-get install -y libopenslide-dev libopenjp2-7
109110
python -m pip install --upgrade pip
111+
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
110112
pip install -r requirements/requirements.txt
111113
pip install build
112114
- name: Build package

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ repos:
6060
- id: rst-inline-touching-normal # Detect mistake of inline code touching normal text in rst.
6161
- repo: https://github.com/astral-sh/ruff-pre-commit
6262
# Ruff version.
63-
rev: v0.14.3
63+
rev: v0.14.7
6464
hooks:
6565
- id: ruff
6666
args: [--fix, --exit-non-zero-on-fix]

requirements/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ SimpleITK>=2.2.1
3232
sphinx>=5.3.0
3333
tifffile>=2022.10.10, <=2025.5.10
3434
timm>=1.0.3
35-
torch>=2.1.0
35+
torch>=2.5.0
3636
torchvision>=0.15.0
3737
tqdm>=4.64.1
3838
umap-learn>=0.5.3

requirements/requirements_dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pytest>=7.2.0
1010
pytest-cov>=4.0.0
1111
pytest-runner>=6.0
1212
pytest-xdist[psutil]
13-
ruff==0.14.3 # This will be updated by pre-commit bot to latest version
13+
ruff==0.14.7 # This will be updated by pre-commit bot to latest version
1414
toml>=0.10.2
1515
twine>=4.0.1
1616
wheel>=0.37.1

tests/models/test_arch_sccnn.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,22 @@ def test_functionality(remote_sample: Callable) -> None:
3939
units="mpp",
4040
coord_space="resolution",
4141
)
42-
batch = torch.from_numpy(patch)[None]
4342
model = _load_sccnn(name="sccnn-crchisto")
43+
patch = model.preproc(patch)
44+
batch = torch.from_numpy(patch)[None]
4445
output = model.infer_batch(
4546
model,
4647
batch,
4748
device=select_device(on_gpu=env_detection.has_gpu()),
4849
)
4950
output = model.postproc(output[0])
50-
assert np.all(output == [[8, 7]])
51+
np.testing.assert_array_equal(output, np.array([[8, 7]]))
52+
5153
model = _load_sccnn(name="sccnn-conic")
5254
output = model.infer_batch(
5355
model,
5456
batch,
5557
device=select_device(on_gpu=env_detection.has_gpu()),
5658
)
5759
output = model.postproc(output[0])
58-
assert np.all(output == [[7, 8]])
60+
np.testing.assert_array_equal(output, np.array([[7, 8]]))

tiatoolbox/data/pretrained_model.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -863,14 +863,14 @@ sccnn-crchisto:
863863
class: semantic_segmentor.IOSegmentorConfig
864864
kwargs:
865865
input_resolutions:
866-
- { "units": "mpp", "resolution": 0.5 }
866+
- { "units": "mpp", "resolution": 0.25 }
867867
output_resolutions:
868-
- { "units": "mpp", "resolution": 0.5 }
868+
- { "units": "mpp", "resolution": 0.25 }
869869
tile_shape: [ 2048, 2048 ]
870870
patch_input_shape: [ 31, 31 ]
871871
patch_output_shape: [ 13, 13 ]
872872
stride_shape: [ 8, 8 ]
873-
save_resolution: { 'units': 'mpp', 'resolution': 0.5 }
873+
save_resolution: { 'units': 'mpp', 'resolution': 0.25 }
874874

875875
sccnn-conic:
876876
hf_repo_id: TIACentre/TIAToolbox_pretrained_weights
@@ -886,14 +886,14 @@ sccnn-conic:
886886
class: semantic_segmentor.IOSegmentorConfig
887887
kwargs:
888888
input_resolutions:
889-
- { "units": "mpp", "resolution": 0.5 }
889+
- { "units": "mpp", "resolution": 0.25 }
890890
output_resolutions:
891-
- { "units": "mpp", "resolution": 0.5 }
891+
- { "units": "mpp", "resolution": 0.25 }
892892
tile_shape: [ 2048, 2048 ]
893893
patch_input_shape: [ 31, 31 ]
894894
patch_output_shape: [ 13, 13 ]
895895
stride_shape: [ 8, 8 ]
896-
save_resolution: { 'units': 'mpp', 'resolution': 0.5 }
896+
save_resolution: { 'units': 'mpp', 'resolution': 0.25 }
897897

898898
nuclick_original-pannuke:
899899
hf_repo_id: TIACentre/TIAToolbox_pretrained_weights

tiatoolbox/models/architecture/sccnn.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def spatially_constrained_layer2(
239239
return sc2 * out_map_threshold
240240

241241
@staticmethod
242-
def preproc(image: torch.Tensor) -> torch.Tensor:
242+
def preproc(image: np.ndarray) -> np.ndarray:
243243
"""Transforming network input to desired format.
244244
245245
This method is model and dataset specific, meaning that it can be replaced by
@@ -309,7 +309,6 @@ def spatially_constrained_layer1(
309309
sigmoid2 = sigmoid[:, 2:3, :, :]
310310
return sigmoid0, sigmoid1, sigmoid2
311311

312-
input_tensor = self.preproc(input_tensor)
313312
l1 = self.layer["l1"]["conv1"](input_tensor)
314313
p1 = self.layer["pool1"](l1)
315314
l2 = self.layer["l2"]["conv1"](p1)

0 commit comments

Comments
 (0)