Skip to content

Commit

Permalink
Improve Camelyon16 benchmark (#296)
Browse files Browse the repository at this point in the history
* feat: Add phikon feature extractor

* feat: Improve Camelyon16 benchmark script

* feat: Add plots
  • Loading branch information
xavier-owkin authored Jan 8, 2024
1 parent 01dc0ce commit ec5af8e
Show file tree
Hide file tree
Showing 12 changed files with 10,428 additions and 4,641 deletions.
3 changes: 2 additions & 1 deletion flamby/datasets/fed_camelyon16/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Baseline,
BaselineLoss,
FedCamelyon16,
Optimizer,
collate_fn,
metric,
)
Expand Down Expand Up @@ -73,7 +74,7 @@ def main(num_workers_torch, log=False, log_period=10, debug=False, cpu_only=Fals
if use_gpu:
m = m.cuda()
loss = BaselineLoss()
optimizer = optim.Adam(m.parameters(), lr=LR)
optimizer = Optimizer(m.parameters(), lr=LR)
if log:
# We create one summarywriter for each seed in order to overlay the plots
writer = SummaryWriter(log_dir=f"./runs/seed{seed}")
Expand Down
16 changes: 8 additions & 8 deletions flamby/datasets/fed_camelyon16/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,16 @@ def __init__(
if len(self.features_paths) < len(self.labels.index):
if not (self.debug):
logging.warning(
f"You have {len(self.features_paths)} features found in \
{str(self.tiles_dir)} instead of {len(self.labels.index)} \
(full Camelyon16 dataset), please go back to the installation \
instructions."
f"You have {len(self.features_paths)} features found in"
f" {str(self.tiles_dir)} instead of {len(self.labels.index)} (full"
" Camelyon16 dataset), please go back to the installation"
" instructions."
)
else:
print(
f"Warning you are operating on a reduced dataset in \
DEBUG mode with in total \
{len(self.features_paths)}/{len(self.labels.index)} features."
"Warning you are operating on a reduced dataset in DEBUG mode with"
" in total {len(self.features_paths)}/{len(self.labels.index)}"
" features."
)

def __len__(self):
Expand Down Expand Up @@ -251,7 +251,7 @@ def __init__(
]


def collate_fn(dataset_elements_list, max_tiles=1000):
def collate_fn(dataset_elements_list, max_tiles=10000):
"""Helper function to correctly batch samples from
a Camelyon16Dataset accomodating for the uneven number of tiles per slide.
Expand Down
2 changes: 1 addition & 1 deletion flamby/datasets/fed_ixi/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def _validate_center(self) -> None:
centers = list(self.CENTER_LABELS.keys()) + list(self.CENTER_LABELS.values())
assert self.centers[0] in centers, (
f"Center {self.centers[0]} "
f"is not compatible with this dataset. "
"is not compatible with this dataset. "
f"Existing centers can be named as follow: {centers} "
)

Expand Down
Loading

0 comments on commit ec5af8e

Please sign in to comment.