Skip to content

Commit

Permalink
Merge branch 'main' into update-leaderboard
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaenzig authored Oct 11, 2024
2 parents 177356d + 26f38dd commit 5ab619d
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ data:
embeddings_transforms:
class_path: eva.core.data.transforms.Pad2DTensor
init_args:
pad_size: 10_000
pad_size: &N_PATCHES ${oc.env:N_PATCHES, 10000}
target_transforms:
class_path: eva.core.data.transforms.dtype.ArrayToFloatTensor
val:
Expand All @@ -103,7 +103,7 @@ data:
sampler:
class_path: eva.vision.data.wsi.patching.samplers.ForegroundGridSampler
init_args:
max_samples: 10_000
max_samples: *N_PATCHES
width: 224
height: 224
target_mpp: 0.25
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ data:
embeddings_transforms:
class_path: eva.core.data.transforms.Pad2DTensor
init_args:
pad_size: &N_PATCHES 500
pad_size: &N_PATCHES ${oc.env:N_PATCHES, 1000}
target_transforms:
class_path: eva.core.data.transforms.dtype.ArrayToFloatTensor
val:
Expand Down
2 changes: 1 addition & 1 deletion configs/vision/pathology/offline/classification/panda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ data:
embeddings_transforms:
class_path: eva.core.data.transforms.Pad2DTensor
init_args:
pad_size: &N_PATCHES 1000
pad_size: &N_PATCHES ${oc.env:N_PATCHES, 1000}
val:
class_path: eva.datasets.MultiEmbeddingsClassificationDataset
init_args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ data:
embeddings_transforms:
class_path: eva.core.data.transforms.Pad2DTensor
init_args:
pad_size: &N_PATCHES 200
pad_size: &N_PATCHES ${oc.env:N_PATCHES, 200}
val:
class_path: eva.datasets.MultiEmbeddingsClassificationDataset
init_args:
Expand Down
8 changes: 4 additions & 4 deletions configs/vision/pathology/offline/segmentation/monusac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ model:
init_args:
softmax: true
batch: true
ignore_index: &IGNORE_INDEX 255
ignore_index: &IGNORE_INDEX 5
optimizer:
class_path: torch.optim.AdamW
init_args:
Expand All @@ -84,17 +84,17 @@ model:
evaluation:
- class_path: eva.vision.metrics.defaults.MulticlassSegmentationMetrics
init_args:
num_classes: *NUM_CLASSES
num_classes: 6
ignore_index: *IGNORE_INDEX
- class_path: torchmetrics.ClasswiseWrapper
init_args:
metric:
class_path: eva.vision.metrics.GeneralizedDiceScore
init_args:
num_classes: *NUM_CLASSES
num_classes: 6
weight_type: linear
per_class: true
ignore_index: *IGNORE_INDEX
per_class: true
data:
class_path: eva.DataModule
init_args:
Expand Down
6 changes: 3 additions & 3 deletions configs/vision/pathology/online/segmentation/monusac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ model:
init_args:
softmax: true
batch: true
ignore_index: &IGNORE_INDEX 255
ignore_index: &IGNORE_INDEX 5
lr_multiplier_encoder: 0.0
optimizer:
class_path: torch.optim.AdamW
Expand All @@ -76,14 +76,14 @@ model:
evaluation:
- class_path: eva.vision.metrics.defaults.MulticlassSegmentationMetrics
init_args:
num_classes: *NUM_CLASSES
num_classes: 6
ignore_index: *IGNORE_INDEX
- class_path: torchmetrics.ClasswiseWrapper
init_args:
metric:
class_path: eva.vision.metrics.GeneralizedDiceScore
init_args:
num_classes: *NUM_CLASSES
num_classes: 6
weight_type: linear
ignore_index: *IGNORE_INDEX
per_class: true
Expand Down
2 changes: 1 addition & 1 deletion src/eva/core/models/transforms/extract_patch_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __call__(
height = width = int(math.sqrt(patch_grid))
if height * width != patch_grid:
if self._ignore_remaining_dims:
features = features[:, :, : height * width]
features = features[:, :, -height * width :]
else:
raise ValueError(f"Patch grid size must be a square number {patch_grid}.")
patch_embeddings = features.view(batch_size, hidden_size, height, width)
Expand Down
10 changes: 5 additions & 5 deletions src/eva/vision/data/datasets/segmentation/monusac.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(
@property
@override
def classes(self) -> List[str]:
return ["Epithelial", "Lymphocyte", "Neutrophil", "Macrophage"]
return ["Background", "Epithelial", "Lymphocyte", "Neutrophil", "Macrophage", "Ambiguous"]

@functools.cached_property
@override
Expand All @@ -107,8 +107,8 @@ def validate(self) -> None:
_validators.check_dataset_integrity(
self,
length=self._expected_dataset_lengths.get(self._split, 0),
n_classes=4,
first_and_last_labels=("Epithelial", "Macrophage"),
n_classes=6,
first_and_last_labels=("Background", "Ambiguous"),
)

@override
Expand Down Expand Up @@ -199,9 +199,9 @@ def _get_semantic_mask(self, index: int) -> npt.NDArray[Any]:
semantic_labels = np.zeros((height, width), "uint8") # type: ignore[reportCallIssue]
for level in range(len(root)):
label = [item.attrib["Name"] for item in root[level][0]][0]
class_id = self.class_to_idx.get(label, 254) + 1
class_id = self.class_to_idx.get(label, self.class_to_idx["Ambiguous"])
# for the test dataset an additional class 'Ambiguous' was added for
# difficult regions with fuzzy boundaries - we return it as 255
# difficult regions with fuzzy boundaries
regions = [item for child in root[level] for item in child if item.tag == "Region"]
for region in regions:
vertices = np.array(
Expand Down

0 comments on commit 5ab619d

Please sign in to comment.