Copy the following commands to the terminal to clone the repository, download the model weights, download the pretrained UNet weights, download the data, and build the Docker image.
# Clone the repository.
git clone [email protected]:VishalJ99/mphil_medical_imaging_cw.git
# Change the working directory to the repository.
cd mphil_medical_imaging_cw
# Download the data.
git clone [email protected]:loressa/DataScience_MPhill_practicals.git
mv DataScience_MPhill_practicals/Dataset Dataset
rm -rf DataScience_MPhill_practicals
# Create the environment.
conda env update --file environment.yml
# Activate the environment.
conda activate mphil_medical_imaging_cw
# De identify the data.
python src/de_identify_dataset.py Dataset/Images
# Build the Docker image.
docker build -t medical_imaging_cw .
Note: It is recommended to run the code locally if using a machine with CUDA or MPS.
Make sure the environment is activated before running the following commands.
python src/train.py configs/train_config.yml
NOTE: NaN dice scores are expected as some slices in the case have no lungs to segment. In such cases the dice score is always 0, so is set to NaN to avoid confusion with a true dice score of 0 (empty pred for non empty ground truth).
python src/test.py configs/test_config.yml
To demo the training of the model on a single case, run the following command:
docker run -it -v $(pwd):/mphil_medical_imaging_cw medical_imaging_cw /bin/bash -c "source activate mphil_medical_imaging_cw && python src/train.py configs/train_config_docker.yml"
To demo the testing of the model on a single case using the pretrained unet, run the following command:
NOTE: NaN dice scores are expected as some slices in the case have no lungs to segment. In such cases the dice score is always 0, so is set to NaN to avoid confusion with a true dice score of 0 (empty pred for non empty ground truth).
docker run -it -v $(pwd):/mphil_medical_imaging_cw medical_imaging_cw /bin/bash -c "source activate mphil_medical_imaging_cw && python src/test.py configs/test_config_docker.yml"
To print the summary statistics of the models performance, run the following command:
Docker:
docker run -it -v $(pwd):/mphil_medical_imaging_cw medical_imaging_cw /bin/bash -c "source activate mphil_medical_imaging_cw && python src/eval.py model_evaluation/docker/metrics.csv"
Or to see evaluation of the fully trained model:
docker run -it -v $(pwd):/mphil_medical_imaging_cw medical_imaging_cw /bin/bash -c "source activate mphil_medical_imaging_cw && python src/eval.py model_evaluation/eval_all_test_slices/metrics.csv"
Run locally (to see the box plots): Note: Will get poor results if looking at the docker metrics since it was not trained on the full dataset.
Ensure environment is activated!
To see docker model evaluation:
python src/eval.py model_evaluation/docker/metrics.csv
To see fully trained model evaluation:
python src/eval.py model_evaluation/eval_all_test_slices/metrics.csv