Skip to content

Commit 42a8a02

Browse files
committed
Update README
1 parent 90cd128 commit 42a8a02

File tree

3 files changed

+33
-29
lines changed

3 files changed

+33
-29
lines changed

README.md

+2-28
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,6 @@ The automatic generation of radiology reports has the potential to assist radiol
1818

1919
After the setup, run "**python create_dataset.py**" in src/dataset/ to create training, val and test csv files, in which each row contains specific information about a single image. See doc string of create_dataset.py for more details.
2020

21-
## Training
21+
## Training and Testing
2222

23-
The full model is trained in 3 training stages:
24-
25-
1. Object detector
26-
2. Object detector + abnormality classification module + region selection module
27-
3. Full model end-to-end
28-
29-
### Object detector
30-
31-
For training the object detector, specify the training configurations (e.g. batch size etc.) in lines 32 - 49 of src/object_detector/training_script_object_detector.py, then run "**python training_script_object_detector.py**".
32-
The weights of the trained object detector model will be stored in the folder specified in src/path_datasets_and_weights.py
33-
34-
### Object detector + abnormality classification module + region selection module
35-
36-
For the second training stage, first specify the path to the best trained object detector in report generation model (see line 26 of src/full_model/report_generation_model.py), such that the trained object detector will be trained together with the 2 binary classifiers.
37-
Next, specify the run configurations in src/full_model/run_configurations.py. In particular, set "**PRETRAIN_WITHOUT_LM_MODEL = True**",
38-
such that the language model is fully excluded from training. See doc string of src/full_model/run_configurations.py for more details.
39-
Start training by running "**python train_full_model.py**" in src/full_model/.
40-
41-
### Full model
42-
43-
For the third training stage, again adjust the run configurations in src/full_model/run_configurations.py (e.g., the batch size may have to be lowered, since the full model requires a lot of memory). In particular, set "**PRETRAIN_WITHOUT_LM_MODEL = False**", such that the full model is trained end-to-end. Next, specify the checkpoint of the best pre-trained model of training stage 2 in the main function (line 567) of src/full_model/train_full_model.py, such this pre-trained model is loaded at beginning of training. Start training by running "**python train_full_model.py**" in src/full_model/.
44-
45-
During each training stage, the validation metrics and other useful information (such as images with bounding boxes and generated sentences etc.) are logged to tensorboard files saved in the corresponding run folders (specified in path_datasets_and_weights.py). Additionally, for the 3rd training stage, txt files with generated reports and sentences are saved in the run folders.
46-
47-
## Testing
48-
49-
Specify the run and checkpoint of the best trained full model to be tested in lines 40 - 41 of src/full_model/test_set_evaluation.py, then run "**python test_set_evaluation.py**". Txt files with the test set scores (and generated reports/sentences) will be saved in src/.
23+
Please read the README_TRAIN_TEST.md for specific information on trainig and testing the model.

README_TRAIN_TEST.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## Training
2+
3+
The full model is trained in 3 training stages:
4+
5+
1. Object detector
6+
2. Object detector + abnormality classification module + region selection module
7+
3. Full model end-to-end (i.e. all 4 modules together)
8+
9+
### Object detector
10+
11+
For training the object detector, specify the training configurations (e.g. batch size etc.) in lines 32 - 49 of src/object_detector/training_script_object_detector.py, then run "**python training_script_object_detector.py**".
12+
The weights of the trained object detector model will be stored in the folder specified in src/path_datasets_and_weights.py
13+
14+
### Object detector + abnormality classification module + region selection module
15+
16+
For the second training stage, first specify the path to the best trained object detector in report generation model (see line 26 of src/full_model/report_generation_model.py), such that the trained object detector will be trained together with the 2 binary classifiers.
17+
Next, specify the run configurations in src/full_model/run_configurations.py. In particular, set "**PRETRAIN_WITHOUT_LM_MODEL = True**",
18+
such that the language model is fully excluded from training. See doc string of src/full_model/run_configurations.py for more details.
19+
Start training by running "**python train_full_model.py**" in src/full_model/.
20+
21+
### Full model
22+
23+
For the third training stage, again adjust the run configurations in src/full_model/run_configurations.py (e.g., the batch size may have to be lowered, since the full model requires a lot of memory). In particular, set "**PRETRAIN_WITHOUT_LM_MODEL = False**", such that the full model is trained end-to-end. Next, specify the checkpoint of the best pre-trained model of training stage 2 in the main function (line 567) of src/full_model/train_full_model.py, such this pre-trained model is loaded at beginning of training. Start training by running "**python train_full_model.py**" in src/full_model/.
24+
25+
During each training stage, the validation metrics and other useful information (such as images with bounding boxes and generated sentences etc.) are logged to tensorboard files saved in the corresponding run folders (specified in path_datasets_and_weights.py). Additionally, for the 3rd training stage, txt files with generated reports and sentences are saved in the run folders.
26+
27+
## Testing
28+
29+
Specify the run and checkpoint of the best trained full model to be tested in lines 40 - 41 of src/full_model/test_set_evaluation.py, then run "**python test_set_evaluation.py**". Txt files with the test set scores (and generated reports/sentences) will be saved in src/.

src/full_model/run_configurations.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
(2) Object detector + binary classifiers training:
1717
- load best object detector weights from step (1) into the object detector in the __init__ method in src/full_model/report_generation_model.py
1818
- set PRETRAIN_WITHOUT_LM_MODEL = True in this file
19-
- make sure that in the main function of src/full_model/train_full_model.py, no other weights are loaded into the instantiated ReportGenerationModel
19+
- make sure that in the main function of src/full_model/train_full_model.py,
20+
no other weights are loaded into the instantiated ReportGenerationModel (i.e. make sure that line 567 is commented out)
2021
- pre-train full model without language model with src/full_model/train_full_model.py
2122
2223
(3) Full model training:

0 commit comments

Comments
 (0)