Yukiya-Umimi / ITUNet-for-PICAI-2022-Challenge

Apache License 2.0
15 stars 5 forks source link

End-to-end Training Pipeline #6

Closed joeranbosma closed 1 year ago

joeranbosma commented 1 year ago

In order to run the training pipeline on SageMaker for the PI-CAI Closed Testing Phase with the Public and Private Training dataset, the full end-to-end pipeline needs to be specified a priori in scripts.

Based on your repository, it appears you do the following steps, but I may be mistaken:

  1. Preprocess data for classification model
  2. Preprocess data for segmentation model
  3. Train classification model (supervised)
  4. Train segmentation model (supervised)
  5. Generate pseudo labels with classification and segmentation model
  6. Train segmentation model (semi-supervised)

Could you confirm this, or let me know the correct sequence?

If correct, it means that the current preprocessing script only prepares the data for the segmentation model, right? If so, the preprocessing script should be extended to also preprocess & export the data for the classification model, essentially including this preprocessing script.

For the training steps, there should be a script that handles the export of trained model weights, as well as any other steps that are now performed manually (including setting paths). For the steps above, I've drafted four training scripts in this PR:

  1. Train classification model (supervised)
  2. Train segmentation model (supervised)
  3. Generate pseudo labels
  4. Train semi-supervised model

The files are merely templates, the training code needs to be added still! The same PR also replaces the picai_eval folder by pip-installing picai_eval.

Pending:

Yukiya-Umimi commented 1 year ago

Hi,

This sequence is ok. The current preprocessing script does not only prepare the data for the segmentation model, but also for the classification model. The last question is a bit complicated. We will retain the three possible optimal weights during the training process, and then the trainer needs to choose the weights he thinks are the best. This selection process may require the prior knowledge of the trainer, such as other reserved parameters during the training process or the prediction results in the validation set, which is difficult to write into a program to run.

Best, Honey K

yukiya

@. | ---- Replied Message ---- | From | Joeran @.> | | Date | 2/26/2023 23:47 | | To | @.> | | Cc | @.> | | Subject | [Yukiya-Umimi/ITUNet-for-PICAI-2022-Challenge] End-to-end Training Pipeline (Issue #6) |

In order to run the training pipeline on SageMaker for the PI-CAI Closed Testing Phase with the Public and Private Training dataset, the full end-to-end pipeline needs to be specified a priori in scripts.

Based on your repository, it appears you do the following steps, but I may be mistaken:

Preprocess data for classification model Preprocess data for segmentation model Train classification model (supervised) Train segmentation model (supervised) Generate pseudo labels with classification and segmentation model Train segmentation model (semi-supervised)

Could you confirm this, or let me know the correct sequence?

If correct, it means that the current preprocessing script only prepares the data for the segmentation model, right? If so, the preprocessing script should be extended to also preprocess & export the data for the classification model.

For the training steps, there should be a script that handles the export of trained model weights, as well as any other steps that are now performed manually (including setting paths). For the steps above, I've drafted four training scripts in this PR:

Train classification model (supervised) Train segmentation model (supervised) Generate pseudo labels Train semi-supervised model

The files are merely templates, the training code needs to be added still!

Pending:

Verify preprocessing pipeline Verify pseudo label generation Verify training pipeline (supervised) Verify training pipeline (semi-supervised) Verify training Docker container

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

Yukiya-Umimi commented 1 year ago

By the way, we don't want to change our code into another form, because we can't guarantee that there will be no errors during this period, which requires a lot of work to verify. We have tested that the current code is executable, and the parts requiring manual operation are very simple. If you have the time and ability to complete this work, you can create a new branch to use your code, and we will also thank you.

yukiya

@. | ---- Replied Message ---- | From | Joeran @.> | | Date | 2/26/2023 23:47 | | To | @.> | | Cc | @.> | | Subject | [Yukiya-Umimi/ITUNet-for-PICAI-2022-Challenge] End-to-end Training Pipeline (Issue #6) |

In order to run the training pipeline on SageMaker for the PI-CAI Closed Testing Phase with the Public and Private Training dataset, the full end-to-end pipeline needs to be specified a priori in scripts.

Based on your repository, it appears you do the following steps, but I may be mistaken:

Preprocess data for classification model Preprocess data for segmentation model Train classification model (supervised) Train segmentation model (supervised) Generate pseudo labels with classification and segmentation model Train segmentation model (semi-supervised)

Could you confirm this, or let me know the correct sequence?

If correct, it means that the current preprocessing script only prepares the data for the segmentation model, right? If so, the preprocessing script should be extended to also preprocess & export the data for the classification model.

For the training steps, there should be a script that handles the export of trained model weights, as well as any other steps that are now performed manually (including setting paths). For the steps above, I've drafted four training scripts in this PR:

Train classification model (supervised) Train segmentation model (supervised) Generate pseudo labels Train semi-supervised model

The files are merely templates, the training code needs to be added still!

Pending:

Verify preprocessing pipeline Verify pseudo label generation Verify training pipeline (supervised) Verify training pipeline (semi-supervised) Verify training Docker container

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

joeranbosma commented 1 year ago

Dear Yukiya,

We understand the difficulty of verifying the training code after restructuring it. However, in order to have a reproducible training pipeline that we can apply to the private training dataset, we require all steps to be performed by explicit scripts. These scripts ensure two factors:

  1. All decisions are specified precisely, to ensure we perform the exact training steps as intended.
  2. The training pipeline is fully automatic, without any manual intervention.

I'm afraid both points are a requirement for the PI-CAI Closed Testing Phase, since we cannot allow any manual intervention.

Just like the restructuring of the preprocessing pipeline (https://github.com/Yukiya-Umimi/ITUNet-for-PICAI-2022-Challenge/pull/2), the adaptations should be simple. I'll see if I can make the PR more explicit, to make my point more clear.

joeranbosma commented 1 year ago

Dear Yukiya,

We ran a debugging run with the preprocessing script from this PR, after which we obtained the following preprocessed dataset structure. The debug dataset consists of 11 cases (10 manually annotated, 1 unlabeled):

```bash ├── classification │   ├── images_illness_3c │   │   ├── 0_0.png │   │   ├── 0_1.png │   │   ├── 0_10.png │   │   ├── 0_11.png │   │   ├── 0_12.png │   │   ├── 0_13.png │   │   ├── 0_14.png │   │   ├── 0_15.png │   │   ├── 0_16.png │   │   ├── 0_17.png │   │   ├── 0_18.png │   │   ├── 0_2.png │   │   ├── 0_3.png │   │   ├── 0_4.png │   │   ├── 0_5.png │   │   ├── 0_6.png │   │   ├── 0_7.png │   │   ├── 0_8.png │   │   └── 0_9.png │   └── picai_illness_3c.csv ├── nnUNet_raw_data │   ├── Task2201_picai_baseline │   │   ├── imagesTr │   │   │   ├── 10000_1000000_0000.nii.gz │   │   │   ├── 10000_1000000_0001.nii.gz │   │   │   ├── 10000_1000000_0002.nii.gz │   │   │   ├── 10001_1000001_0000.nii.gz │   │   │   ├── 10001_1000001_0001.nii.gz │   │   │   ├── 10001_1000001_0002.nii.gz │   │   │   ├── 10002_1000002_0000.nii.gz │   │   │   ├── 10002_1000002_0001.nii.gz │   │   │   ├── 10002_1000002_0002.nii.gz │   │   │   ├── 10003_1000003_0000.nii.gz │   │   │   ├── 10003_1000003_0001.nii.gz │   │   │   ├── 10003_1000003_0002.nii.gz │   │   │   ├── 10004_1000004_0000.nii.gz │   │   │   ├── 10004_1000004_0001.nii.gz │   │   │   ├── 10004_1000004_0002.nii.gz │   │   │   ├── 10005_1000005_0000.nii.gz │   │   │   ├── 10005_1000005_0001.nii.gz │   │   │   ├── 10005_1000005_0002.nii.gz │   │   │   ├── 10006_1000006_0000.nii.gz │   │   │   ├── 10006_1000006_0001.nii.gz │   │   │   ├── 10006_1000006_0002.nii.gz │   │   │   ├── 10007_1000007_0000.nii.gz │   │   │   ├── 10007_1000007_0001.nii.gz │   │   │   ├── 10007_1000007_0002.nii.gz │   │   │   ├── 10009_1000009_0000.nii.gz │   │   │   ├── 10009_1000009_0001.nii.gz │   │   │   ├── 10009_1000009_0002.nii.gz │   │   │   ├── 10010_1000010_0000.nii.gz │   │   │   ├── 10010_1000010_0001.nii.gz │   │   │   └── 10010_1000010_0002.nii.gz │   │   └── labelsTr │   │   ├── 10000_1000000.nii.gz │   │   ├── 10001_1000001.nii.gz │   │   ├── 10002_1000002.nii.gz │   │   ├── 10003_1000003.nii.gz │   │   ├── 10004_1000004.nii.gz │   │   ├── 10005_1000005.nii.gz │   │   ├── 10006_1000006.nii.gz │   │   ├── 10007_1000007.nii.gz │   │   ├── 10009_1000009.nii.gz │   │   └── 10010_1000010.nii.gz │   └── picai_prep_20230307173139.log ├── nnUNet_test_data │   ├── 10008_1000008_0000.nii.gz │   ├── 10008_1000008_0001.nii.gz │   └── 10008_1000008_0002.nii.gz └── segmentation └── segdata ├── data_2d │   ├── 0_0.hdf5 │   ├── 0_1.hdf5 │   ├── 0_10.hdf5 │   ├── 0_11.hdf5 │   ├── 0_12.hdf5 │   ├── 0_13.hdf5 │   ├── 0_14.hdf5 │   ├── 0_15.hdf5 │   ├── 0_16.hdf5 │   ├── 0_17.hdf5 │   ├── 0_18.hdf5 │   ├── 0_2.hdf5 │   ├── 0_3.hdf5 │   ├── 0_4.hdf5 │   ├── 0_5.hdf5 │   ├── 0_6.hdf5 │   ├── 0_7.hdf5 │   ├── 0_8.hdf5 │   └── 0_9.hdf5 └── data_3d └── 0.hdf5 ```
joeranbosma commented 1 year ago

Dear Yukiya,

I've set up the first explicit training script in this PR: the classification model can now be trained using this Docker container.

Could you review the two PRs (https://github.com/Yukiya-Umimi/ITUNet-for-PICAI-2022-Challenge/pull/5 and https://github.com/Yukiya-Umimi/ITUNet-for-PICAI-2022-Challenge/pull/7)?