Skip to content

Commit

Permalink
final repo
Browse files Browse the repository at this point in the history
Added final repo cleaned for camera-ready version
  • Loading branch information
CamilleDelgrange committed Oct 22, 2024
1 parent 0b75ca3 commit f25596d
Show file tree
Hide file tree
Showing 53 changed files with 8,477 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__pycache__
wandb
runs
outputs
132 changes: 132 additions & 0 deletions configs/config_finetuning.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
defaults:
- _self_
- models: resnet50
- dataset: ukb_stroke

# Command Center
pretrain: False
run_eval: True

algorithm_name: EVAL_PRETRAIN

seeds:
- 2022
- 2023
- 2024
- 2025
- 2026
lr_finder_lrs:
- 3.e-2
- 1.e-2
- 3.e-3
- 1.e-3
- 3.e-4
- 1.e-4
multitarget:

wandb_entity: #PUT HERE YOUR WANDB ENTITY
data_base: #PUT HERE YOUR DATABASE FOLDER
num_workers: 4

wandb_project: #PUT HERE YOUR WANDB PROJECT NAME

# Multimodal
lr: 1.e-4
weight_decay: 5.e-3
scheduler: anneal
anneal_max_epochs: 200
warmup_epochs: 10
temperature: 0.15
projection_dim: 128
use_projection_head: True
strategy:

loss: clip
hard_neg: False
view: augmented
lambda_0: 0.5
momentum: 0.99

train_similarity_matrix:
val_similarity_matrix:
threshold: 0.9
similarity_divisor: 2

tabular_pretrain_checkpoint:
pretrained_tabular_strategy: frozen
imaging_pretrain_checkpoint:
pretrained_imaging_strategy: trainable

multiple_lr: False

batch_size: 6 #512
lr_eval: 1e-5 #scaled by gradient acc
weight_decay_eval: 1e-3
val_check_interval: 1.0
check_val_every_n_epoch: 1
tabular_embedding_dim: 2048

# Classifier
classifier_num_layers: 2
lr_classifier: 3.e-4
weight_decay_classifier: 1.e-4
online_mlp: False

# Imaging
augmentation_rate: 0.95
crop_scale_lower: 0.08

# tabular
corruption_rate: 0.3
one_hot: True
eval_one_hot: True

encoder_num_layers: 2
projector_num_layers: 1
init_strat: kaiming
dropout_rate: 0.3

# Evaluator
generate_embeddings: False
keep_projector: False
eval_train_augment_rate: 0.8
eval_classifier: linear
finetune_strategy: trainable
optimizer_eval: adamw
youden_index: False
youden_index_eval: True
gradcam: True

vec2vec: False
checkpoint_vec2vec:

# PUT here the pretrained checkpoint of the best pretrained multimodal model:
checkpoint: PATH_TO_REPO/runs/multimodal/gentle-sound-239/last.ckpt
checkpoint_imaging: False
checkpoint_tabular: False
checkpoint_multimodal: True
datatype: multimodal
eval_datatype: imaging_and_tabular
task: classification
fig_dir:
grad_cam_strategy: accumulation

# General
seed: 2022
max_epochs: 50
log_images: False
use_wandb: True
limit_train_batches: 1.0
limit_val_batches: 1.0
limit_test_batches: 1.0
enable_progress_bar: True
log_every_n_steps: 1
offline: False
evaluate: True
test: False
test_and_eval: True
combine_train_and_val: False
weighted_sampler: False
stratified_sampler: True
classifier_freq: 1
unit_test: False
129 changes: 129 additions & 0 deletions configs/config_pretraining.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
defaults:
- _self_
- models: resnet50
- dataset: ukb_stroke

# Command Center
pretrain: True
run_eval: False

algorithm_name:

seeds:
- 2022
- 2023
- 2024
- 2025
- 2026
lr_finder_lrs:
- 3.e-2
- 1.e-2
- 3.e-3
- 1.e-3
- 3.e-4
- 1.e-4
multitarget:

wandb_entity: #PUT HERE YOUR WANDB ENTITY
data_base: #PUT HERE YOUR DATABASE FOLDER
num_workers: 10

wandb_project: #PUT HERE YOUR WANDB PROJECT NAME

# Multimodal
lr: 1.e-3
weight_decay: 1.e-3
scheduler: anneal
anneal_max_epochs: 200
warmup_epochs: 10
temperature: 0.08
projection_dim: 128
use_projection_head: True
strategy:

loss: clip
hard_neg: False
view: augmented
lambda_0: 0.5
momentum: 0.99

train_similarity_matrix:
val_similarity_matrix:
threshold: 0.9
similarity_divisor: 2

tabular_pretrain_checkpoint:
pretrained_tabular_strategy: frozen
imaging_pretrain_checkpoint:
pretrained_imaging_strategy: trainable

multiple_lr: False

batch_size: 6 #512
lr_eval: 1.e-5 #scaled by gradient acc
weight_decay_eval: 1e-4
val_check_interval: 1.0
check_val_every_n_epoch: 1
tabular_embedding_dim: 2048

# Classifier
classifier_num_layers: 2
lr_classifier: 3.e-4
weight_decay_classifier: 1.e-4
online_mlp: False

# Imaging
augmentation_rate: 0.95
crop_scale_lower: 0.08

# tabular
corruption_rate: 0.3
one_hot: True
eval_one_hot: True

encoder_num_layers: 2
projector_num_layers: 1
init_strat: kaiming
dropout_rate: 0.3

# Evaluator
generate_embeddings: False
keep_projector: False
eval_train_augment_rate: 0.8
eval_classifier: linear
finetune_strategy: trainable
optimizer_eval: adamw
youden_index: False
youden_index_eval: True

vec2vec: False
checkpoint_vec2vec:

checkpoint:
checkpoint_imaging: False
checkpoint_tabular: False
checkpoint_multimodal: True
datatype: multimodal
eval_datatype: imaging_and_tabular
task: classification
gradcam: True
fig_dir:

# General
seed: 2022
max_epochs: 100
log_images: False
use_wandb: True
limit_train_batches: 1.0
limit_val_batches: 1.0
limit_test_batches: 1.0
enable_progress_bar: True
log_every_n_steps: 1
offline: False
evaluate: True
test: False
test_and_eval: True
combine_train_and_val: False
weighted_sampler: False
stratified_sampler: True
classifier_freq: 1
46 changes: 46 additions & 0 deletions configs/dataset/ukb_stroke.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# @package _global_
defaults:
- _self_

target: stroke

num_classes: 2
weights: #[0.55, 10] # To check for model evaluation!!
# For the images, provide a .pt with a list of your images or a list of the paths to your images.
# For big dataset need to save only paths to load live. If providing a list of paths, set live_loading=True.
live_loading: True
delete_segmentation: False
balanced_accuracy: True
eval_metric: auc

# num of features
num_cat: 29
num_con: 18

field_lengths_tabular: /PATH_TO_YOUR_DOCUMENT/field_lengths_tabular.pt

columns_name: /PATH_TO_YOUR_DOCUMENT/features_columns.txt

data_train_tabular: /PATH_TO_SPLIT_PRETRAINING_TRAIN_SET_FEATURES/features_pretrain_train_all_patients.csv
data_val_tabular: /PATH_TO_SPLIT_PRETRAINING_VAL_SET_FEATURES/features_pretrain_val_all_patients.csv

data_train_imaging: /PATH_TO_SPLIT_PRETRAINING_TRAIN_SET_IMG_PATHS/image_paths_pretrain_train_all_patients.pt
data_val_imaging: /PATH_TO_SPLIT_PRETRAINING_VAL_SET_IMG_PATHS/image_paths_pretrain_val_all_patients.pt


# For the online classifier during self-supervised pre-training
labels_train: /PATH_TO_SPLIT_PRETRAINING_TRAIN_SET_LABELS/labels_pretrain_train_all_patients.pt
labels_val: /PATH_TO_SPLIT_PRETRAINING_VAL_SET_LABELS/labels_pretrain_val_all_patients.pt

# For the downstream task, this should be balanced for train, val and test:
data_train_eval_tabular: /PATH_TO_SPLIT_TRAIN_SET_FEATURES/features_train.csv
data_train_eval_imaging: /PATH_TO_SPLIT_TRAIN_SET_IMG_PATHS/image_paths_train.pt
labels_train_eval: /PATH_TO_SPLIT_TRAIN_SET_LABELS/labels_train.pt

data_val_eval_tabular: /PATH_TO_SPLIT_VAL_SET_FEATURES/features_val.csv
data_val_eval_imaging: /PATH_TO_SPLIT_VAL_SET_IMG_PATHS/image_paths_val.pt
labels_val_eval: /PATH_TO_SPLIT_VAL_SET_LABELS/labels_val.pt

data_test_eval_tabular: /PATH_TO_SPLIT_TEST_SET_FEATURES/features_test.csv
data_test_eval_imaging: /PATH_TO_SPLIT_TEST_SET_IMG_PATHS/image_paths_test.pt
labels_test_eval_imaging: /PATH_TO_SPLIT_TEST_SET_LABELSlabels_test.pt
14 changes: 14 additions & 0 deletions configs/models/resnet18.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# @package _global_
defaults:
- _self_

model: resnet18
lr: 3.e-4
img_size: 128
embedding_dim: 512
is_training: False
is_ssl: True
original_height: 182

lr_imaging: 3.e-4
lr_tabular: 3.e-4
14 changes: 14 additions & 0 deletions configs/models/resnet50.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# @package _global_
defaults:
- _self_

model: resnet50
lr: 3.e-4
img_size: 80
embedding_dim: 2048
is_training: False
is_ssl: True
original_height: 182

lr_imaging: 3.e-4
lr_tabular: 3.e-4
20 changes: 20 additions & 0 deletions configs/models/resnet_customBT.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# @package _global_
defaults:
- _self_

model: resnetcustom
lr: 0.5
img_size: 128
z_dim: 2048
is_training: False
is_ssl: True
original_height: 182

# ResNet:
in_channels: 1
n_blocks: 6
bn_momentum: 0.05
n_basefilters: 16
dropout_rate: 0.1
resnet_version: 'base'
remain_downsample_steps: null
Loading

0 comments on commit f25596d

Please sign in to comment.