Skip to content

Commit

Permalink
Fixing detector path
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianHoerst committed Apr 5, 2024
1 parent 9983ee4 commit f35b340
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 8 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,5 @@ jobs:
run: python -m pytest -vv -s ./tests/test_macenko_module
- name : Run Core Tests
run: python -m pytest -vv -s ./tests/test_core_modules
- name : Run Dicom Tests
run: python -m pytest -vv -s ./tests/test_dicom_module
- name : Run Dataset and Dataloader Tests
run: python -m pytest -vv -s ./tests/test_pytorch_dataset
2 changes: 1 addition & 1 deletion pathopatch/patch_extraction/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def _set_tissue_detector(self) -> None:
model = mobilenet_v3_small().to(device=self.detector_device)
model.classifier[-1] = nn.Linear(1024, 4)
checkpoint = torch.load(
"./pathopatch/data/tissue_detector.pt", # this causes errors
"/pathopatch/data/tissue_detector.pt", # this causes errors
map_location=self.detector_device,
)
model.load_state_dict(checkpoint["model_state_dict"])
Expand Down
4 changes: 3 additions & 1 deletion pathopatch/patch_extraction/patch_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,9 @@ def _set_tissue_detector(self) -> None:
model = mobilenet_v3_small().to(device=self.detector_device)
model.classifier[-1] = nn.Linear(1024, 4)
checkpoint = torch.load(
"./pathopatch/data/tissue_detector.pt", # this causes errors
(
Path(os.path.dirname(__file__)).parent / "data" / "tissue_detector.pt"
).resolve(),
map_location=self.detector_device,
)
model.load_state_dict(checkpoint["model_state_dict"])
Expand Down
9 changes: 8 additions & 1 deletion pathopatch/wsi_interfaces/wsidicomizer_openslide.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ def __init__(self, dcm_folder: Union[Path, str]) -> None:
self.level_count: int
self.level_downsamples: List[float]

source = WsiDicomFileSource.open(dcm_folder)
# iterate through the folder to check if a DICOMDIR file exists
dcm_folder = Path(dcm_folder)
files = [f for f in dcm_folder.iterdir() if f.is_file()]
if not any(f.name == "DICOMDIR" for f in files):
source = WsiDicomFileSource.open(dcm_folder)
else:
source = WsiDicomFileSource.open_dicomdir(dcm_folder / "DICOMDIR")

super().__init__(source, True)

# information and properties to make this compatible with OpenSlide
Expand Down
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

VERSION = "1.0.1b"
VERSION = "1.0.4b"
DESCRIPTION = "PathoPatch - Accelerating Artificial Intelligence Based Whole Slide Image Analysis with an Optimized Preprocessing Pipeline"
with open("docs/README_pypi.md", "r") as fh:
LONG_DESCRIPTION = fh.read()
Expand Down Expand Up @@ -39,8 +39,8 @@
"tqdm",
"torchvision",
"torch",
"wsidicom=0.20.4",
"wsidicomizer=0.13.2",
"wsidicom==0.20.4",
"wsidicomizer==0.13.2",
],
scripts=[
"pathopatch/wsi_extraction.py",
Expand All @@ -64,4 +64,6 @@
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Other",
],
include_package_data=True,
package_data={"pathopatch": ["data/*"]},
)
6 changes: 6 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
python -m pytest -vv -s ./tests/test_cli
python -m pytest -vv -s ./tests/test_utils
python -m pytest -vv -s ./tests/test_macenko_module
python -m pytest -vv -s ./tests/test_core_modules
python -m pytest -vv -s ./tests/test_dicom_module
python -m pytest -vv -s ./tests/test_pytorch_dataset
1 change: 1 addition & 0 deletions test_database/download_links.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
https://openslide.cs.cmu.edu/download/openslide-testdata/Aperio/CMU-1.svs
https://openslide.cs.cmu.edu/download/openslide-testdata/Aperio/CMU-1-Small-Region.svs
https://openslide.cs.cmu.edu/download/openslide-testdata/Aperio/JP2K-33003-1.svs
https://drive.google.com/uc?export=download&id=15EjjYxtWf3_o_H4REckK1A0A8JGbpWC6
3 changes: 3 additions & 0 deletions tests/static_test_files/preprocessing/baseline/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ processes: 8
# other
log_level: debug
overwrite: True

apply_prefilter: True
filter_patches: True

0 comments on commit f35b340

Please sign in to comment.