ivadomed / model-seg-dcm

Segmentation of lesions on MRI scans in patients with Degenerative Cervical Myelopathy (DCM)
MIT License
3 stars 0 forks source link

SSL pre-training and fine-tuning on `(64, 64, 64)` samples #9

Open valosekj opened 5 months ago

valosekj commented 5 months ago

This issue summarizes the follow-up experiment to https://github.com/ivadomed/model-seg-dcm/issues/7.

Pre-training

In https://github.com/ivadomed/model-seg-dcm/issues/7., the entire input image of size (64, 256, 256) was used to create two augmeted views. Here, two random samples of size (64, 64, 64) are taken from the input image to create the augmented view using these transforms. Moreover, these samples are taken around a label (spinal cord mask) using RandCropByPosNegLabeld:

image
valosekj commented 5 months ago

I tried three experiments, all for 500 epochs, modifying:

batch_size=8, 5 holes

Reconstructed images across epochs: link

👉 visually looks the best, training now for more epochs

loss_plots ![loss_plots](https://github.com/ivadomed/model-seg-dcm/assets/39456460/c593a5c5-0c5b-4105-9cd9-39e3901ecf97)

batch_size=8, 10 holes

Reconstructed images across epochs: link

loss_plots ![loss_plots](https://github.com/ivadomed/model-seg-dcm/assets/39456460/fff6c1ec-66a2-48b8-b0bf-c888feb0bcad)

batch_size=16, 10 holes

Reconstructed images across epochs: link

loss_plots ![loss_plots](https://github.com/ivadomed/model-seg-dcm/assets/39456460/02cc4c4f-a15a-459f-969a-210d105c7f93)
valosekj commented 5 months ago

Two experiments with RandCoarseDropoutd augmentation transform: fill_value=None vs fill_value=0. Discussion here. Both used batch_size=8, 5 holes, and 1500 epochs.

RandCoarseDropoutd fill_value=None

= filling the dropped regions with randomly selected value based on the min and max value of input image

Reconstructed images across epochs: link

loss_plots ![loss_plots](https://github.com/ivadomed/model-seg-dcm/assets/39456460/c436f5e5-493b-4ada-8ec6-a18d4dfae050)

RandCoarseDropoutd fill_value=0

= filling the dropped regions with value 0

Reconstructed images across epochs: link

loss_plots ![loss_plots](https://github.com/ivadomed/model-seg-dcm/assets/39456460/c41136bd-2a71-4331-95cc-c73d36d88686)
valosekj commented 5 months ago

Fine-tuning on dcm-zurich-lesions

Since the pre-training seems to work (at least the code does not raise errors and the model is learning to reconstruct the images), I performed two fine-tuning experiments: using a pre-trained model vs training from scratch.

Pre-trained model

Fine-tuning using the SSL pre-trained model with RandCoarseDropoutd fill_value=0 (see comment above).

finetune loss plots --> crashed to zero ![image](https://github.com/ivadomed/model-seg-dcm/assets/39456460/fe66bb7b-f67c-43f3-a8a7-f226ed57146f)

Although the learning crashed, the model was learning something! See the validation figure below.

validation figure ![image](https://github.com/ivadomed/model-seg-dcm/assets/39456460/7c045133-2130-47d6-8864-6a47778b8132)

Training from scratch

Fine-tuning from the scratch (weights were initialized randomly).

loss plots --> crashed to zero ![image](https://github.com/ivadomed/model-seg-dcm/assets/39456460/6f5f878e-8236-401c-868e-c81beb6343d7)