-
Install the packages in
requirements.txt:python -m pip install -r requirements.txt jupyterlab
-
If you are running the notebooks on Windows, set any
num_workersorNUM_WORKERSvalue to0in the notebook configuration cells before training or evaluation. This avoids commonDataLoadermultiprocessing issues on Windows. -
Keep the notebooks in the project root.
-
Make sure the dataset folders are available locally.
Dataset_Splits/Task2_Test_Set/
If the dataset folders aren't available locally but you have the zip files, please run 0_Extract_Provided_Datasets.ipynb notebook first to extract
the zip files to ./Dataset_Splits and ./Task2_Test_Set. However, we assume that the markers already have the extracted folders, so this notebook
may not be needed in that case.
Most of our notebooks have an Update These Paths if Needed cell. Those paths may need to be updated if Dataset_Splits and Task2_Test_Set folders are not
located in the root of our repository.
./models - Some of our notebooks will save models to this directory, which may be used by another notebook. For example, 1b_Segmentation.ipynb uses the
model saved by 1b_Autoencoder.ipynb notebook. Unless there have been changes to the model paths within any of our notebooks, there is no need to update
these paths.
1_Dataset_Investigation.ipynbUse this first to inspect the image, tissue, and nuclei data.1a_UNet.ipynbEnd-to-end UNet tissue segmentation. Saves a best checkpoint to./models/unet_final_best.pth.1b_Autoencoder.ipynbTrain the autoencoder / encoder pretraining stage. Saves an autoencoder checkpoint such as./models/autoencoder_weights_large.pth.1b_Segmentation.ipynbFinal segmentation model using the pretrained encoder.encoder_weights_path_custompoints to the checkpoint saved by1b_Autoencoder.ipynbat./models/autoencoder_weights_large.pth. Saves a best checkpoint to./models/segmentation_final_best.pth.
2_DatasetCreation.ipynbCreates the patch dataset fromDataset_Splitsand writes it to./Task2_Patches/.2a_Classification.ipynbEnd-to-end classification using./Task2_Patches/train,./Task2_Patches/val, and./Task2_Test_Set. Saves./models/efficientnet_best.pth.2b_Contrastive.ipynbContrastive pretraining on./Task2_Patches/contrastive. Produces a contrastive checkpoint such as./models/contrastive_temp03_<time>.pth. The later classification stage in this notebook saves./models/contrastive_b64_SimCLR.pth.2b_Contrastive_Supervised.ipynbSupervised contrastive pretraining + classification fine-tuning. Saves./models/contrastive_b64_SupCon_60+.pthand then./models/SupCon_PreTrain_FrozenEnc_best.pth.2x_Visualise_Contrastive.ipynbRun this after contrastive training to visualize embeddings and nearest neighbours.
- If only the zip files are available, start with
0_Extract_Provided_Datasets.ipynb. Otherwise, start with the next step. - Run the dataset investigation notebook
1_Dataset_Investigation.ipynb. - Run the Task 1 notebooks. For Task 1 Part a model, run
1a_UNet.ipynb. For Task 1 Part b model, first run1b_Autoencoder.ipynband then run1b_Segmentation.ipynb. - Run the Task 2 notebooks. First, run
2_DatasetCreation.ipynbto create the patch dataset. For Task 2 Part a model, run2a_Classification.ipynb. For Task 2 Part b models, run2b_Contrastive.ipynband2b_Contrastive_Supervised.ipynb. - Run
2x_Visualise_Contrastive.ipynb.
After running all notebooks, the project may contain the following output directories:
./Dataset_Splits/./Task2_Test_Set/./models/./runs/./Task2_Patches/./Task2_Patches/train/./Task2_Patches/train/tumor/./Task2_Patches/train/lymphocyte/./Task2_Patches/train/histiocyte/./Task2_Patches/val/./Task2_Patches/val/tumor/./Task2_Patches/val/lymphocyte/./Task2_Patches/val/histiocyte/./Task2_Patches/contrastive/./Task2_Patches/contrastive/tumor/./Task2_Patches/contrastive/lymphocyte/./Task2_Patches/contrastive/histiocyte/./task1a_figures/./task2a_figures/