Skip to content

Commit

Permalink
Adapt to upstream dlup
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasteuwen committed Oct 12, 2023
1 parent 7414103 commit 3401fea
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions ahcore/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from dlup import SlideImage
from dlup._image import Resampling
from dlup.annotations import WsiAnnotations
from dlup.data.dataset import ConcatDataset, TiledROIsSlideImageDataset
from dlup.data.transforms import RenameLabels, convert_annotations
from dlup.data.dataset import ConcatDataset, TiledWsiDataset
from dlup.data.transforms import convert_annotations, rename_labels
from dlup.tiling import Grid, GridOrder, TilingMode
from dlup.writers import TiffCompression, TifffileImageWriter
from pytorch_lightning.callbacks import Callback
Expand Down Expand Up @@ -119,8 +119,9 @@ def _generate_regions(self) -> list[tuple[int, int]]:
"""
regions = []
for coordinates in self._grid:
if self._mask is None or self._is_masked((coordinates[0], coordinates[1])):
regions.append(coordinates)
_coordinates = (coordinates[0], coordinates[1])
if self._mask is None or self._is_masked(_coordinates):
regions.append(_coordinates)
return regions

def _is_masked(self, coordinates: tuple[int, int]) -> bool:
Expand Down Expand Up @@ -201,9 +202,7 @@ def _get_annotation_data(
raise ValueError("Index map is not provided.")

_annotations = self._annotations.read_region(coordinates, self._scaling, self._region_size)
_annotations = RenameLabels(remap_labels=self._data_description.remap_labels)({"annotations": _annotations})[
"annotations"
]
_annotations = rename_labels(_annotations, remap_labels=self._data_description.remap_labels)

points, boxes, region, roi = convert_annotations(
_annotations,
Expand Down Expand Up @@ -361,7 +360,7 @@ def _batch_end(
f"TrainerFn {trainer.state.fn} is not supported for {self.__class__.__name__}."
)

current_dataset: TiledROIsSlideImageDataset
current_dataset: TiledWsiDataset
current_dataset, _ = total_dataset.index_to_dataset(self._dataset_index) # type: ignore
slide_image = current_dataset.slide_image

Expand Down

0 comments on commit 3401fea

Please sign in to comment.