Skip to content

Commit

Permalink
Merge branch 'main' into update-user-guide-and-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ioangatop authored Mar 7, 2024
2 parents 093087f + b2d5df8 commit 79815a6
Show file tree
Hide file tree
Showing 42 changed files with 1,198 additions and 77 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ lib64/
parts/
sdist/
var/
tmp/
wheels/
share/python-wheels/
*.egg-info/
Expand Down
8 changes: 5 additions & 3 deletions configs/vision/dino_vit/offline/bach.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
trainer:
class_path: eva.Trainer
init_args:
default_root_dir: &LIGHTNING_ROOT ${oc.env:LIGHTNING_ROOT, logs/dino_vits16/offline/bach}
n_runs: 5
default_root_dir: &OUTPUT_ROOT ${oc.env:OUTPUT_ROOT, logs/${oc.env:DINO_BACKBONE, dino_vits16}/offline/bach}
max_steps: &MAX_STEPS 12500
callbacks:
- class_path: pytorch_lightning.callbacks.LearningRateMonitor
Expand All @@ -23,7 +24,7 @@ trainer:
mode: *MONITOR_METRIC_MODE
- class_path: eva.callbacks.EmbeddingsWriter
init_args:
output_dir: &EMBEDDINGS_DIR ${oc.env:EMBEDDINGS_ROOT, ./data/embeddings}/bach
output_dir: &EMBEDDINGS_DIR ${oc.env:EMBEDDINGS_ROOT, ./data/embeddings}/${oc.env:DINO_BACKBONE, dino_vits16}/bach
dataloader_idx_map:
0: train
1: val
Expand All @@ -35,10 +36,11 @@ trainer:
repo_or_dir: facebookresearch/dino:main
model: ${oc.env:DINO_BACKBONE, dino_vits16}
pretrained: ${oc.env:PRETRAINED, true}
checkpoint_path: ${oc.env:CHECKPOINT_PATH, null}
logger:
- class_path: pytorch_lightning.loggers.TensorBoardLogger
init_args:
save_dir: *LIGHTNING_ROOT
save_dir: *OUTPUT_ROOT
name: ""
model:
class_path: eva.HeadModule
Expand Down
8 changes: 5 additions & 3 deletions configs/vision/dino_vit/offline/crc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
trainer:
class_path: eva.Trainer
init_args:
default_root_dir: &LIGHTNING_ROOT ${oc.env:LIGHTNING_ROOT, logs/dino_vits16/offline/crc}
n_runs: 5
default_root_dir: &OUTPUT_ROOT ${oc.env:OUTPUT_ROOT, logs/${oc.env:DINO_BACKBONE, dino_vits16}/offline/crc}
max_steps: &MAX_STEPS 12500
callbacks:
- class_path: pytorch_lightning.callbacks.LearningRateMonitor
Expand All @@ -23,7 +24,7 @@ trainer:
mode: *MONITOR_METRIC_MODE
- class_path: eva.callbacks.EmbeddingsWriter
init_args:
output_dir: &EMBEDDINGS_DIR ${oc.env:EMBEDDINGS_ROOT, ./data/embeddings}/crc
output_dir: &EMBEDDINGS_DIR ${oc.env:EMBEDDINGS_ROOT, ./data/embeddings}/${oc.env:DINO_BACKBONE, dino_vits16}/crc
dataloader_idx_map:
0: train
1: val
Expand All @@ -35,10 +36,11 @@ trainer:
repo_or_dir: facebookresearch/dino:main
model: ${oc.env:DINO_BACKBONE, dino_vits16}
pretrained: ${oc.env:PRETRAINED, true}
checkpoint_path: ${oc.env:CHECKPOINT_PATH, null}
logger:
- class_path: pytorch_lightning.loggers.TensorBoardLogger
init_args:
save_dir: *LIGHTNING_ROOT
save_dir: *OUTPUT_ROOT
name: ""
model:
class_path: eva.HeadModule
Expand Down
8 changes: 5 additions & 3 deletions configs/vision/dino_vit/offline/crc_nonorm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
trainer:
class_path: eva.Trainer
init_args:
default_root_dir: &LIGHTNING_ROOT ${oc.env:LIGHTNING_ROOT, logs/dino_vits16/offline/crc_nonorm}
n_runs: 5
default_root_dir: &OUTPUT_ROOT ${oc.env:OUTPUT_ROOT, logs/${oc.env:DINO_BACKBONE, dino_vits16}/offline/crc_nonorm}
max_steps: &MAX_STEPS 12500
callbacks:
- class_path: pytorch_lightning.callbacks.LearningRateMonitor
Expand All @@ -23,7 +24,7 @@ trainer:
mode: *MONITOR_METRIC_MODE
- class_path: eva.callbacks.EmbeddingsWriter
init_args:
output_dir: &EMBEDDINGS_DIR ${oc.env:EMBEDDINGS_ROOT, ./data/embeddings}/crc_nonorm
output_dir: &EMBEDDINGS_DIR ${oc.env:EMBEDDINGS_ROOT, ./data/embeddings}/${oc.env:DINO_BACKBONE, dino_vits16}/crc_nonorm
dataloader_idx_map:
0: train
1: val
Expand All @@ -35,10 +36,11 @@ trainer:
repo_or_dir: facebookresearch/dino:main
model: ${oc.env:DINO_BACKBONE, dino_vits16}
pretrained: ${oc.env:PRETRAINED, true}
checkpoint_path: ${oc.env:CHECKPOINT_PATH, null}
logger:
- class_path: pytorch_lightning.loggers.TensorBoardLogger
init_args:
save_dir: *LIGHTNING_ROOT
save_dir: *OUTPUT_ROOT
name: ""
model:
class_path: eva.HeadModule
Expand Down
8 changes: 5 additions & 3 deletions configs/vision/dino_vit/offline/patch_camelyon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
trainer:
class_path: eva.Trainer
init_args:
default_root_dir: &LIGHTNING_ROOT ${oc.env:LIGHTNING_ROOT, logs/dino_vits16/offline/patch_camelyon}
n_runs: 5
default_root_dir: &OUTPUT_ROOT ${oc.env:OUTPUT_ROOT, logs/${oc.env:DINO_BACKBONE, dino_vits16}/offline/patch_camelyon}
max_steps: &MAX_STEPS 12500
callbacks:
- class_path: pytorch_lightning.callbacks.LearningRateMonitor
Expand All @@ -23,7 +24,7 @@ trainer:
mode: *MONITOR_METRIC_MODE
- class_path: eva.callbacks.EmbeddingsWriter
init_args:
output_dir: &EMBEDDINGS_DIR ${oc.env:EMBEDDINGS_ROOT, ./data/embeddings}/patch_camelyon
output_dir: &EMBEDDINGS_DIR ${oc.env:EMBEDDINGS_ROOT, ./data/embeddings}/${oc.env:DINO_BACKBONE, dino_vits16}/patch_camelyon
dataloader_idx_map:
0: train
1: val
Expand All @@ -36,10 +37,11 @@ trainer:
repo_or_dir: facebookresearch/dino:main
model: ${oc.env:DINO_BACKBONE, dino_vits16}
pretrained: ${oc.env:PRETRAINED, true}
checkpoint_path: ${oc.env:CHECKPOINT_PATH, null}
logger:
- class_path: pytorch_lightning.loggers.TensorBoardLogger
init_args:
save_dir: *LIGHTNING_ROOT
save_dir: *OUTPUT_ROOT
name: ""
model:
class_path: eva.HeadModule
Expand Down
4 changes: 2 additions & 2 deletions configs/vision/dino_vit/online/bach.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
trainer:
class_path: eva.Trainer
init_args:
default_root_dir: &LIGHTNING_ROOT ${oc.env:LIGHTNING_ROOT, logs/dino_vits16/online/bach}
default_root_dir: &OUTPUT_ROOT ${oc.env:OUTPUT_ROOT, logs/${oc.env:DINO_BACKBONE, dino_vits16}/online/bach}
max_steps: &MAX_STEPS 12500
callbacks:
- class_path: pytorch_lightning.callbacks.LearningRateMonitor
Expand All @@ -24,7 +24,7 @@ trainer:
logger:
- class_path: pytorch_lightning.loggers.TensorBoardLogger
init_args:
save_dir: *LIGHTNING_ROOT
save_dir: *OUTPUT_ROOT
name: ""
model:
class_path: eva.HeadModule
Expand Down
5 changes: 3 additions & 2 deletions configs/vision/dino_vit/online/crc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
trainer:
class_path: eva.Trainer
init_args:
default_root_dir: &LIGHTNING_ROOT ${oc.env:LIGHTNING_ROOT, logs/dino_vits16/online/crc}
default_root_dir: &OUTPUT_ROOT ${oc.env:OUTPUT_ROOT, logs/${oc.env:DINO_BACKBONE, dino_vits16}/online/crc}
max_steps: &MAX_STEPS 12500
callbacks:
- class_path: pytorch_lightning.callbacks.LearningRateMonitor
Expand All @@ -24,7 +24,7 @@ trainer:
logger:
- class_path: pytorch_lightning.loggers.TensorBoardLogger
init_args:
save_dir: *LIGHTNING_ROOT
save_dir: *OUTPUT_ROOT
name: ""
model:
class_path: eva.HeadModule
Expand All @@ -37,6 +37,7 @@ model:
repo_or_dir: facebookresearch/dino:main
model: ${oc.env:DINO_BACKBONE, dino_vits16}
pretrained: ${oc.env:PRETRAINED, true}
checkpoint_path: &CHECKPOINT_PATH ${oc.env:CHECKPOINT_PATH, null}
head:
class_path: torch.nn.Linear
init_args:
Expand Down
5 changes: 3 additions & 2 deletions configs/vision/dino_vit/online/crc_nonorm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
trainer:
class_path: eva.Trainer
init_args:
default_root_dir: &LIGHTNING_ROOT ${oc.env:LIGHTNING_ROOT, logs/dino_vits16/online/crc_nonorm}
default_root_dir: &OUTPUT_ROOT ${oc.env:OUTPUT_ROOT, logs/${oc.env:DINO_BACKBONE, dino_vits16}/online/crc_nonorm}
max_steps: &MAX_STEPS 12500
callbacks:
- class_path: pytorch_lightning.callbacks.LearningRateMonitor
Expand All @@ -24,7 +24,7 @@ trainer:
logger:
- class_path: pytorch_lightning.loggers.TensorBoardLogger
init_args:
save_dir: *LIGHTNING_ROOT
save_dir: *OUTPUT_ROOT
name: ""
model:
class_path: eva.HeadModule
Expand All @@ -37,6 +37,7 @@ model:
repo_or_dir: facebookresearch/dino:main
model: ${oc.env:DINO_BACKBONE, dino_vits16}
pretrained: ${oc.env:PRETRAINED, true}
checkpoint_path: &CHECKPOINT_PATH ${oc.env:CHECKPOINT_PATH, null}
head:
class_path: torch.nn.Linear
init_args:
Expand Down
6 changes: 3 additions & 3 deletions configs/vision/dino_vit/online/patch_camelyon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
trainer:
class_path: eva.Trainer
init_args:
default_root_dir: &LIGHTNING_ROOT ${oc.env:LIGHTNING_ROOT, logs/dino_vits16/online/patch_camelyon}
default_root_dir: &OUTPUT_ROOT ${oc.env:OUTPUT_ROOT, logs/${oc.env:DINO_BACKBONE, dino_vits16}/online/patch_camelyon}
max_steps: &MAX_STEPS 12500
callbacks:
- class_path: pytorch_lightning.callbacks.LearningRateMonitor
Expand All @@ -24,7 +24,7 @@ trainer:
logger:
- class_path: pytorch_lightning.loggers.TensorBoardLogger
init_args:
save_dir: *LIGHTNING_ROOT
save_dir: *OUTPUT_ROOT
name: ""
model:
class_path: eva.HeadModule
Expand All @@ -37,7 +37,7 @@ model:
repo_or_dir: facebookresearch/dino:main
model: ${oc.env:DINO_BACKBONE, dino_vits16}
pretrained: ${oc.env:PRETRAINED, true}
checkpoint_path: &CHECKPOINT_PATH ${oc.env:CHECKPOINT_PATH, null}
checkpoint_path: ${oc.env:CHECKPOINT_PATH, null}
head:
class_path: torch.nn.Linear
init_args:
Expand Down
107 changes: 107 additions & 0 deletions configs/vision/owkin/phikon/offline/bach.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
trainer:
class_path: eva.Trainer
init_args:
n_runs: 5
default_root_dir: &OUTPUT_ROOT ${oc.env:OUTPUT_ROOT, logs/${oc.env:DINO_BACKBONE, owkin/phikon}/offline/bach}
max_steps: &MAX_STEPS 12500
callbacks:
- class_path: pytorch_lightning.callbacks.LearningRateMonitor
init_args:
logging_interval: epoch
- class_path: pytorch_lightning.callbacks.ModelCheckpoint
init_args:
filename: best
save_last: true
save_top_k: 1
monitor: &MONITOR_METRIC ${oc.env:MONITOR_METRIC, val/MulticlassAccuracy}
mode: &MONITOR_METRIC_MODE ${oc.env:MONITOR_METRIC_MODE, max}
- class_path: pytorch_lightning.callbacks.EarlyStopping
init_args:
min_delta: 0
patience: 800
monitor: *MONITOR_METRIC
mode: *MONITOR_METRIC_MODE
- class_path: eva.callbacks.EmbeddingsWriter
init_args:
output_dir: &EMBEDDINGS_DIR ${oc.env:EMBEDDINGS_ROOT, ./data/embeddings}/${oc.env:DINO_BACKBONE, owkin/phikon}/bach
dataloader_idx_map:
0: train
1: val
backbone:
class_path: eva.models.wrappers.HuggingFaceModel
init_args:
model_name_or_path: owkin/phikon
tensor_transforms:
class_path: eva.vision.data.transforms.model_output.ExtractCLSFeatures
logger:
- class_path: pytorch_lightning.loggers.TensorBoardLogger
init_args:
save_dir: *OUTPUT_ROOT
name: ""
model:
class_path: eva.HeadModule
init_args:
head:
class_path: torch.nn.Linear
init_args:
in_features: ${oc.env:IN_FEATURES, 768}
out_features: &NUM_CLASSES 4
criterion: torch.nn.CrossEntropyLoss
optimizer:
class_path: torch.optim.SGD
init_args:
lr: &LR_VALUE 0.00064
momentum: 0.9
weight_decay: 0.0
lr_scheduler:
class_path: torch.optim.lr_scheduler.CosineAnnealingLR
init_args:
T_max: *MAX_STEPS
eta_min: 0.0
metrics:
common:
- class_path: eva.metrics.AverageLoss
- class_path: eva.metrics.MulticlassClassificationMetrics
init_args:
num_classes: *NUM_CLASSES
data:
class_path: eva.DataModule
init_args:
datasets:
train:
class_path: eva.vision.data.datasets.embeddings.PatchEmbeddingDataset
init_args: &DATASET_ARGS
root: *EMBEDDINGS_DIR
split: train
column_mapping:
path: embedding
val:
class_path: eva.vision.data.datasets.embeddings.PatchEmbeddingDataset
init_args:
<<: *DATASET_ARGS
split: val
predict:
- class_path: eva.vision.datasets.BACH
init_args: &PREDICT_DATASET_ARGS
root: ${oc.env:DATA_ROOT, ./data}/bach
split: train
download: ${oc.env:DOWNLOAD_DATA, true}
image_transforms:
class_path: eva.vision.data.transforms.common.ResizeAndCrop
init_args:
size: ${oc.env:RESIZE_DIM, 224}
mean: ${oc.env:NORMALIZE_MEAN, [0.485, 0.456, 0.406]}
std: ${oc.env:NORMALIZE_STD, [0.229, 0.224, 0.225]}
- class_path: eva.vision.datasets.BACH
init_args:
<<: *PREDICT_DATASET_ARGS
split: val
dataloaders:
train:
batch_size: &BATCH_SIZE 256
shuffle: true
val:
batch_size: *BATCH_SIZE
predict:
batch_size: &PREDICT_BATCH_SIZE ${oc.env:PREDICT_BATCH_SIZE, 128}
Loading

0 comments on commit 79815a6

Please sign in to comment.