Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add KiTS23 dataset #727

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ tests/eva/assets/**/*.npy filter=lfs diff=lfs merge=lfs -text
tests/eva/assets/**/*.xml filter=lfs diff=lfs merge=lfs -text
tests/eva/assets/**/*.mat filter=lfs diff=lfs merge=lfs -text
tests/eva/assets/**/*.nii filter=lfs diff=lfs merge=lfs -text
tests/eva/assets/**/*.nii.gz filter=lfs diff=lfs merge=lfs -text
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,3 @@ cython_debug/

# numpy data
*.npy

# NiFti data
*.nii.gz
158 changes: 158 additions & 0 deletions configs/vision/radiology/offline/segmentation/kits23.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
---
trainer:
class_path: eva.Trainer
init_args:
n_runs: &N_RUNS ${oc.env:N_RUNS, 5}
default_root_dir: &OUTPUT_ROOT ${oc.env:OUTPUT_ROOT, logs/${oc.env:MODEL_NAME, vit_small_patch16_224_dino}/kits23}
max_steps: &MAX_STEPS ${oc.env:MAX_STEPS, 40000}
checkpoint_type: ${oc.env:CHECKPOINT_TYPE, best}
callbacks:
- class_path: eva.callbacks.ConfigurationLogger
- class_path: lightning.pytorch.callbacks.TQDMProgressBar
init_args:
refresh_rate: ${oc.env:TQDM_REFRESH_RATE, 1}
- class_path: eva.vision.callbacks.SemanticSegmentationLogger
init_args:
log_every_n_epochs: 1
log_images: false
- class_path: lightning.pytorch.callbacks.ModelCheckpoint
init_args:
filename: best
save_last: true
save_top_k: 1
monitor: &MONITOR_METRIC ${oc.env:MONITOR_METRIC, 'val/MonaiDiceScore'}
mode: &MONITOR_METRIC_MODE ${oc.env:MONITOR_METRIC_MODE, max}
- class_path: lightning.pytorch.callbacks.EarlyStopping
init_args:
min_delta: 0
patience: ${oc.env:PATIENCE, 5}
monitor: *MONITOR_METRIC
mode: *MONITOR_METRIC_MODE
- class_path: eva.callbacks.SegmentationEmbeddingsWriter
init_args:
output_dir: &DATASET_EMBEDDINGS_ROOT ${oc.env:EMBEDDINGS_ROOT, ./data/embeddings}/${oc.env:MODEL_NAME, vit_small_patch16_224_dino}/kits23
dataloader_idx_map:
0: train
1: val
2: test
metadata_keys: ["slice_index"]
overwrite: false
backbone:
class_path: eva.vision.models.ModelFromRegistry
init_args:
model_name: ${oc.env:MODEL_NAME, universal/vit_small_patch16_224_dino}
model_kwargs:
out_indices: ${oc.env:OUT_INDICES, 1}
model_extra_kwargs: ${oc.env:MODEL_EXTRA_KWARGS, null}
logger:
- class_path: lightning.pytorch.loggers.TensorBoardLogger
init_args:
save_dir: *OUTPUT_ROOT
name: ""
model:
class_path: eva.vision.models.modules.SemanticSegmentationModule
init_args:
decoder:
class_path: eva.vision.models.networks.decoders.segmentation.ConvDecoderMS
init_args:
in_features: ${oc.env:IN_FEATURES, 384}
num_classes: &NUM_CLASSES 4
criterion:
class_path: eva.vision.losses.DiceLoss
init_args:
softmax: true
batch: true
lr_multiplier_encoder: 0.0
optimizer:
class_path: torch.optim.AdamW
init_args:
lr: ${oc.env:LR_VALUE, 0.002}
lr_scheduler:
class_path: torch.optim.lr_scheduler.PolynomialLR
init_args:
total_iters: *MAX_STEPS
power: 0.9
postprocess:
predictions_transforms:
- class_path: torch.argmax
init_args:
dim: 1
metrics:
common:
- class_path: eva.metrics.AverageLoss
evaluation:
- class_path: eva.vision.metrics.defaults.MulticlassSegmentationMetrics
init_args:
num_classes: *NUM_CLASSES
- class_path: torchmetrics.ClasswiseWrapper
init_args:
metric:
class_path: eva.vision.metrics.MonaiDiceScore
init_args:
include_background: true
num_classes: *NUM_CLASSES
reduction: none
labels:
- background
- kidney
- tumor
- cyst
data:
class_path: eva.DataModule
init_args:
datasets:
train:
class_path: eva.vision.datasets.EmbeddingsSegmentationDataset
init_args: &DATASET_ARGS
root: *DATASET_EMBEDDINGS_ROOT
manifest_file: manifest.csv
split: train
val:
class_path: eva.vision.datasets.EmbeddingsSegmentationDataset
init_args:
<<: *DATASET_ARGS
split: val
test:
class_path: eva.vision.datasets.EmbeddingsSegmentationDataset
init_args:
<<: *DATASET_ARGS
split: test
predict:
- class_path: eva.vision.datasets.KiTS23
init_args: &PREDICT_DATASET_ARGS
root: ${oc.env:DATA_ROOT, ./data/kits23}
split: train
download: ${oc.env:DOWNLOAD_DATA, false}
# Set `download: true` to download the dataset automatically from the official source.
# The KiTS23 dataset is distributed under the following license:
# "Attribution-NonCommercial-ShareAlike 4.0 International"
# (see: https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en)
transforms:
class_path: eva.vision.data.transforms.common.ResizeAndClamp
init_args:
size: ${oc.env:RESIZE_DIM, 224}
mean: &NORMALIZE_MEAN ${oc.env:NORMALIZE_MEAN, [0.485, 0.456, 0.406]}
std: &NORMALIZE_STD ${oc.env:NORMALIZE_STD, [0.229, 0.224, 0.225]}
- class_path: eva.vision.datasets.KiTS23
init_args:
<<: *PREDICT_DATASET_ARGS
split: val
- class_path: eva.vision.datasets.KiTS23
init_args:
<<: *PREDICT_DATASET_ARGS
split: test
dataloaders:
train:
batch_size: &BATCH_SIZE ${oc.env:BATCH_SIZE, 64}
num_workers: &N_DATA_WORKERS ${oc.env:N_DATA_WORKERS, 4}
shuffle: true
val:
batch_size: *BATCH_SIZE
num_workers: *N_DATA_WORKERS
shuffle: true
test:
batch_size: *BATCH_SIZE
num_workers: *N_DATA_WORKERS
predict:
batch_size: &PREDICT_BATCH_SIZE ${oc.env:PREDICT_BATCH_SIZE, 64}
num_workers: *N_DATA_WORKERS
132 changes: 132 additions & 0 deletions configs/vision/radiology/online/segmentation/kits23.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
trainer:
class_path: eva.Trainer
init_args:
n_runs: &N_RUNS ${oc.env:N_RUNS, 5}
default_root_dir: &OUTPUT_ROOT ${oc.env:OUTPUT_ROOT, logs/${oc.env:MODEL_NAME, vit_small_patch16_224_dino}/kits23}
max_steps: &MAX_STEPS ${oc.env:MAX_STEPS, 40000}
checkpoint_type: ${oc.env:CHECKPOINT_TYPE, best}
callbacks:
- class_path: eva.callbacks.ConfigurationLogger
- class_path: lightning.pytorch.callbacks.TQDMProgressBar
init_args:
refresh_rate: ${oc.env:TQDM_REFRESH_RATE, 1}
- class_path: eva.vision.callbacks.SemanticSegmentationLogger
init_args:
log_every_n_epochs: 1
mean: &NORMALIZE_MEAN ${oc.env:NORMALIZE_MEAN, [0.485, 0.456, 0.406]}
std: &NORMALIZE_STD ${oc.env:NORMALIZE_STD, [0.229, 0.224, 0.225]}
- class_path: lightning.pytorch.callbacks.ModelCheckpoint
init_args:
filename: best
save_last: true
save_top_k: 1
monitor: &MONITOR_METRIC ${oc.env:MONITOR_METRIC, 'val/MonaiDiceScore'}
mode: &MONITOR_METRIC_MODE ${oc.env:MONITOR_METRIC_MODE, max}
- class_path: lightning.pytorch.callbacks.EarlyStopping
init_args:
min_delta: 0
patience: ${oc.env:PATIENCE, 5}
monitor: *MONITOR_METRIC
mode: *MONITOR_METRIC_MODE
logger:
- class_path: lightning.pytorch.loggers.TensorBoardLogger
init_args:
save_dir: *OUTPUT_ROOT
name: ""
model:
class_path: eva.vision.models.modules.SemanticSegmentationModule
init_args:
encoder:
class_path: eva.vision.models.ModelFromRegistry
init_args:
model_name: ${oc.env:MODEL_NAME, universal/vit_small_patch16_224_dino}
model_kwargs:
out_indices: ${oc.env:OUT_INDICES, 1}
model_extra_kwargs: ${oc.env:MODEL_EXTRA_KWARGS, null}
decoder:
class_path: eva.vision.models.networks.decoders.segmentation.ConvDecoderWithImage
init_args:
in_features: ${oc.env:IN_FEATURES, 384}
num_classes: &NUM_CLASSES 4
criterion:
class_path: eva.vision.losses.DiceLoss
init_args:
softmax: true
batch: true
lr_multiplier_encoder: 0.0
optimizer:
class_path: torch.optim.AdamW
init_args:
lr: ${oc.env:LR_VALUE, 0.002}
lr_scheduler:
class_path: torch.optim.lr_scheduler.PolynomialLR
init_args:
total_iters: *MAX_STEPS
power: 0.9
postprocess:
predictions_transforms:
- class_path: torch.argmax
init_args:
dim: 1
metrics:
common:
- class_path: eva.metrics.AverageLoss
evaluation:
- class_path: eva.vision.metrics.defaults.MulticlassSegmentationMetrics
init_args:
num_classes: *NUM_CLASSES
- class_path: torchmetrics.ClasswiseWrapper
init_args:
metric:
class_path: eva.vision.metrics.MonaiDiceScore
init_args:
include_background: true
num_classes: *NUM_CLASSES
reduction: none
labels:
- background
- kidney
- tumor
- cyst
data:
class_path: eva.DataModule
init_args:
datasets:
train:
class_path: eva.vision.datasets.KiTS23
init_args: &DATASET_ARGS
root: ${oc.env:DATA_ROOT, ./data/kits23}
split: train
download: ${oc.env:DOWNLOAD_DATA, false}
# Set `download: true` to download the dataset automatically from the official source.
# The KiTS23 dataset is distributed under the following license:
# "Attribution-NonCommercial-ShareAlike 4.0 International"
# (see: https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en)
transforms:
class_path: eva.vision.data.transforms.common.ResizeAndClamp
init_args:
mean: *NORMALIZE_MEAN
std: *NORMALIZE_STD
val:
class_path: eva.vision.datasets.KiTS23
init_args:
<<: *DATASET_ARGS
split: val
test:
class_path: eva.vision.datasets.KiTS23
init_args:
<<: *DATASET_ARGS
split: test
dataloaders:
train:
batch_size: &BATCH_SIZE ${oc.env:BATCH_SIZE, 64}
num_workers: &N_DATA_WORKERS ${oc.env:N_DATA_WORKERS, 4}
shuffle: true
val:
batch_size: *BATCH_SIZE
num_workers: *N_DATA_WORKERS
shuffle: true
test:
batch_size: *BATCH_SIZE
num_workers: *N_DATA_WORKERS
2 changes: 2 additions & 0 deletions src/eva/vision/data/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
CoNSeP,
EmbeddingsSegmentationDataset,
ImageSegmentation,
KiTS23,
LiTS,
LiTSBalanced,
MoNuSAC,
Expand All @@ -36,6 +37,7 @@
"CoNSeP",
"EmbeddingsSegmentationDataset",
"ImageSegmentation",
"KiTS23",
"LiTS",
"LiTSBalanced",
"MoNuSAC",
Expand Down
2 changes: 2 additions & 0 deletions src/eva/vision/data/datasets/segmentation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from eva.vision.data.datasets.segmentation.bcss import BCSS
from eva.vision.data.datasets.segmentation.consep import CoNSeP
from eva.vision.data.datasets.segmentation.embeddings import EmbeddingsSegmentationDataset
from eva.vision.data.datasets.segmentation.kits23 import KiTS23
from eva.vision.data.datasets.segmentation.lits import LiTS
from eva.vision.data.datasets.segmentation.lits_balanced import LiTSBalanced
from eva.vision.data.datasets.segmentation.monusac import MoNuSAC
Expand All @@ -14,6 +15,7 @@
"BCSS",
"CoNSeP",
"EmbeddingsSegmentationDataset",
"KiTS23",
"LiTS",
"LiTSBalanced",
"MoNuSAC",
Expand Down
Loading
Loading