Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
ca37400
Merge pull request #1 from TissueImageAnalytics/develop
mbasheer04 Jan 17, 2025
dab2693
Merge branch 'TissueImageAnalytics:develop' into develop
mbasheer04 Jan 24, 2025
bc6afda
Squashed commit of the following:
mbasheer04 Jan 24, 2025
5f8032d
Merge branch 'develop' of https://github.com/mbasheer04/tiatoolbox in…
mbasheer04 Jan 24, 2025
a543460
Integrating SAM into bokeh
mbasheer04 Jan 30, 2025
c620ca4
Added save file for GeneralSegmentor output
mbasheer04 Jan 30, 2025
9217b69
Added on-click prompt segementation to TIAViz
mbasheer04 Feb 19, 2025
60f4d5f
Added multi-prompt segmentation & bounding-box
mbasheer04 Feb 20, 2025
09a79fd
Added scores to masks
mbasheer04 Feb 22, 2025
1a4a76c
Attempting to add resolution/window-based segmentation
mbasheer04 Feb 26, 2025
b322539
Successfully implemented window-based segmentation
mbasheer04 Feb 27, 2025
35237c4
Fixing issues
mbasheer04 Mar 4, 2025
6ad56fe
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 20, 2025
2cb7d9c
Merge branch 'develop' into sam-viz
shaneahmed Mar 21, 2025
7b403c9
Preparing for PR
mbasheer04 Mar 20, 2025
a8f2938
Merge branch 'sam-viz' of https://github.com/mbasheer04/tiatoolbox in…
mbasheer04 Mar 27, 2025
6e8b859
Restoring notebook changes
mbasheer04 Mar 27, 2025
51ecbe9
Pre-commit fixes
mbasheer04 Mar 28, 2025
fd3a2c2
Added centroid extraction
mbasheer04 Apr 3, 2025
315d2c8
Merge branch 'develop' into sam-viz
shaneahmed Apr 4, 2025
a5d5971
Merge branch 'develop' into sam-viz
adamshephard Apr 10, 2025
ec9b76c
Improving Engine
mbasheer04 Apr 11, 2025
5db9657
Removing eval files
mbasheer04 Apr 11, 2025
e193646
Merge branch 'sam-viz' of https://github.com/mbasheer04/tiatoolbox in…
mbasheer04 Apr 11, 2025
effdadc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 11, 2025
f69dfb7
Cleaning up code
mbasheer04 Apr 11, 2025
c02f153
Merge branch 'sam-viz' of https://github.com/mbasheer04/tiatoolbox in…
mbasheer04 Apr 11, 2025
c1cb059
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 11, 2025
71eedb2
Added docstrings
mbasheer04 Apr 16, 2025
0878a66
Added SAM to requirements.txt
mbasheer04 Apr 17, 2025
65d72aa
Added pretrained model and fixed requirements
mbasheer04 Apr 24, 2025
be52c04
Adding engine unit tests
mbasheer04 Apr 25, 2025
2517844
Improving unit tests
mbasheer04 Apr 25, 2025
210ad2d
Improving unit tests
mbasheer04 Apr 29, 2025
821a848
Add store from #926
mbasheer04 Apr 29, 2025
5bf382b
Added annotation-based save for engine
mbasheer04 May 1, 2025
b5afc18
Merge branch 'develop' into sam-viz
mbasheer04 May 2, 2025
fbfa884
Fixing DeepSource issues
mbasheer04 May 2, 2025
37939c3
Merge branch 'sam-viz' of https://github.com/mbasheer04/tiatoolbox in…
mbasheer04 May 2, 2025
673c318
Debugging engine
mbasheer04 May 7, 2025
63d8012
Switched to transformers
mbasheer04 May 8, 2025
5c3656a
Finishing unit tests
mbasheer04 May 9, 2025
fd0539e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 9, 2025
01af916
Fixing deepsource
mbasheer04 May 9, 2025
311295d
Merge branch 'develop' into sam-viz
mbasheer04 May 9, 2025
c992fc8
Merge branch 'sam-viz' of https://github.com/mbasheer04/tiatoolbox in…
mbasheer04 May 9, 2025
4765906
Fixing build errors
mbasheer04 May 9, 2025
73150f2
Merge branch 'develop' into sam-viz
mbasheer04 May 9, 2025
7f122b3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 9, 2025
cc4f883
Fixing more build errors
mbasheer04 May 9, 2025
9c0e1bd
Merge branch 'sam-viz' of https://github.com/mbasheer04/tiatoolbox in…
mbasheer04 May 9, 2025
53374aa
Fixing arch test
mbasheer04 May 9, 2025
0e13290
Removed whole image mask generation
mbasheer04 May 10, 2025
6190647
Added missing exception tests
mbasheer04 May 10, 2025
94e09f1
Fixed image encoding to work with non-square images
mbasheer04 May 11, 2025
c24016c
Fixing issues with tile mode
mbasheer04 May 12, 2025
c7d3dc6
Fixed TIAViz issues
mbasheer04 May 12, 2025
85b1148
Added mask again
mbasheer04 May 12, 2025
2499251
initial fix
measty Oct 18, 2025
660a118
remove old promptsegmentor
measty Nov 7, 2025
b1d92b0
Merge branch 'develop' of https://github.com/TissueImageAnalytics/tia…
measty Nov 7, 2025
442e8a9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 7, 2025
c4869f2
Merge branch 'develop' into sam-viz-fix
shaneahmed Nov 28, 2025
3a58797
Merge branch 'develop' into sam-viz-fix
shaneahmed Dec 5, 2025
8a47302
Merge branch 'develop' into sam-viz-fix
shaneahmed Dec 19, 2025
a0781fb
Merge branch 'develop' into sam-viz-fix
shaneahmed Jan 9, 2026
6fc325e
Merge branch 'develop' of https://github.com/TissueImageAnalytics/tia…
measty Jan 15, 2026
929d405
remove outdated tests
measty Jan 15, 2026
89a69a7
precommit fixes
measty Jan 15, 2026
0df23b0
scale attribute
measty Jan 15, 2026
0a5ece9
update test
measty Jan 15, 2026
e285c53
standardize inputs
measty Jan 15, 2026
82b30b2
fix test
measty Jan 15, 2026
95851a8
revert unecessary change
measty Jan 15, 2026
a4aa37e
add test
measty Jan 16, 2026
6c72547
deepsource...
measty Jan 16, 2026
b84ef7f
coverage
measty Jan 16, 2026
8ccf953
fix offset
measty Jan 16, 2026
d44ed93
mix box and pts
measty Jan 16, 2026
4fb94a8
coverage
measty Jan 16, 2026
44e99d1
Merge branch 'develop' into sam-viz-fix
shaneahmed Jan 22, 2026
b54a704
Merge branch 'develop' into sam-viz-fix
measty Feb 9, 2026
e79fb78
address comments
measty Feb 13, 2026
1319baf
add clear button
measty Feb 13, 2026
de88f10
:recycle: Restructure the code to improve coverage.
shaneahmed Feb 13, 2026
01d822f
Merge branch 'develop' into sam-viz-fix
shaneahmed Feb 14, 2026
08a8f3c
:twisted_rightwards_arrows: Merge `develop` into `sam-viz-fix`
shaneahmed Mar 5, 2026
8451978
:bulb: Address Co-Pilot comments and fix bug
shaneahmed Mar 5, 2026
99f1e7f
fix test
measty Mar 5, 2026
e0078c8
:+1: Add `ignore_index` to segmentation masks
shaneahmed Mar 6, 2026
eb41f50
:white_check_mark: Update tests to include ignore_index
shaneahmed Mar 6, 2026
fe570f5
Merge branch 'develop' into sam-viz-fix
shaneahmed Mar 6, 2026
a4939c1
:bug: Fix grandqc tests
shaneahmed Mar 6, 2026
157dfd6
add clear button
measty Mar 6, 2026
c23152d
Merge branch 'sam-viz-fix' of https://github.com/TissueImageAnalytics…
measty Mar 6, 2026
9c048a5
add test
measty Mar 6, 2026
0b7b795
address copilot comments
measty Mar 6, 2026
1d6272d
Merge branch 'develop' of https://github.com/TissueImageAnalytics/tia…
measty Mar 6, 2026
27f07a3
coverage
measty Mar 6, 2026
6d2d8a5
Merge branch 'develop' into sam-viz-fix
shaneahmed Mar 8, 2026
6bc1908
:white_check_mark: Add tests for coverage
shaneahmed Mar 8, 2026
5b195cc
:white_check_mark: Add tests for coverage
shaneahmed Mar 8, 2026
f3b62d0
:bug: Fix deepsource errors
shaneahmed Mar 8, 2026
1111e42
Merge branch 'develop' into sam-viz-fix
shaneahmed Mar 9, 2026
44a961b
:white_check_mark: Add tests for coverage
shaneahmed Mar 9, 2026
8bf1576
:bug: Fix deepsource errors.
shaneahmed Mar 9, 2026
1badd12
:bug: Fix deepsource errors.
shaneahmed Mar 9, 2026
c5d48f2
:white_check_mark: Add test_make_window_edges_on_true
shaneahmed Mar 9, 2026
3a21b25
:white_check_mark: Add test_docconfig_no_config_file
shaneahmed Mar 9, 2026
4c6e203
Merge branch 'develop' into sam-viz-fix
shaneahmed Mar 9, 2026
c9183a9
:white_check_mark: Add tests for coverage
shaneahmed Mar 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ timm>=1.0.3
torch>=2.5.0
torchvision>=0.15.0
tqdm>=4.64.1
transformers>=4.51.1
umap-learn>=0.5.3
wsidicom>=0.18.0
zarr>=2.13.3, <3.0.0
2 changes: 0 additions & 2 deletions tests/engines/test_semantic_segmentor.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ def _test_qupath_output_patch(output: Path) -> None:
assert "Polygon" in geometry_types

# When class_dict is None, types are assigned as 0, 1, ...
assert 0 in class_values
assert 1 in class_values

# Basic sanity check
Expand Down Expand Up @@ -1071,7 +1070,6 @@ def _test_store_output_patch(output: Path) -> None:
if "type" in probs:
annotation_types.add(probs.pop("type"))
# When class_dict is none, types are assigned as 0, 1, ...
assert 0 in annotation_types
assert 1 in annotation_types

assert annotations_properties is not None
4 changes: 2 additions & 2 deletions tests/models/test_arch_grandqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_grandqc_with_semantic_segmentor(
assert Path(output[sample_image]).exists()

store = SQLiteStore.open(output[sample_image])
assert len(store) == 4
assert len(store) == 3

unique_types = set()

Expand All @@ -116,7 +116,7 @@ def test_grandqc_with_semantic_segmentor(
tissue_area_px += annotation.geometry.area
assert 2950000 < tissue_area_px < 2960000

assert unique_types == {"background", "tissue"}
assert unique_types == {"tissue"}
store.close()


Expand Down
61 changes: 61 additions & 0 deletions tests/models/test_arch_sam.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""Unit test package for SAM."""

from collections.abc import Callable
from pathlib import Path

import numpy as np
import pytest
import torch

from tiatoolbox.models.architecture.sam import SAM
from tiatoolbox.utils import env_detection as toolbox_env
from tiatoolbox.utils import imread
from tiatoolbox.utils.misc import select_device

ON_GPU = toolbox_env.has_gpu()

# Test pretrained Model =============================


def test_functional_sam(remote_sample: Callable) -> None:
"""Test for SAM."""
# convert to pathlib Path to prevent wsireader complaint
tile_path = Path(remote_sample("patch-extraction-vf"))
img = imread(tile_path)

# test creation

model = SAM(device=select_device(on_gpu=ON_GPU))

# create image patch and prompts
points = np.array([[[64, 64]]])
boxes = np.array([[[64, 64, 128, 128]]])

# test preproc
tensor = torch.from_numpy(img)
patch = np.expand_dims(model.preproc(tensor), axis=0)
patch = model.preproc(patch)

# test inference

mask_output, score_output = model.infer_batch(
model, patch, points, device=select_device(on_gpu=ON_GPU)
)

assert mask_output is not None, "Output should not be None"
assert len(mask_output) > 0, "Output should have at least one element"
assert len(score_output) > 0, "Output should have at least one element"

mask_output, score_output = model.infer_batch(
model, patch, box_coords=boxes, device=select_device(on_gpu=ON_GPU)
)

assert len(mask_output) > 0, "Output should have at least one element"
assert len(score_output) > 0, "Output should have at least one element"

# test error when no prompts provided
with pytest.raises(
ValueError,
match=r"At least one of point_coords or box_coords must be provided.",
):
_ = model.infer_batch(model, patch, device=select_device(on_gpu=ON_GPU))
Loading
Loading