Here we present the full flow of creating docker image that supports the following features:
- Full preprocessing for dicom and nifti files including:
- dicom to nifti
- segmentation
- cropping
- anomaly detection
- risk classification
- origin classification
Create a folder called web_service_models
it should be like the following:
├── web_service_models
│ ├── anomaly_detection
│ │ ├── model_1
│ │ │ ├── best_val_model.pt
│ │ │ ├── config.json
│ │ ├── model_2
│ │ │ ├── ...
│ ├── risk_classification
│ │ ├── model_1
│ │ │ ├── best_val_model.pt
│ │ │ ├── config.json
│ │ ├── model_2
│ │ │ ├── ...
│ ├── origin_classification
│ │ ├── model_1
│ │ │ ├── best_val_model.pt
│ │ │ ├── config.json
│ │ ├── model_2
│ │ │ ├── ...
│ ├── cardiac_segmentation
│ │ ├── plans.json
│ │ ├── dataset.json
│ │ ├── fold_0
│ │ │ ├── checkpoint_final.pth
│ │ ├── ...
Build the image using the following command:
docker build . -t narco_script:latest
Create two folders namely input
and output
. Then, put input image in the input directory and then run one of the following commands.
docker run --rm -v ./input:/app/input -v ./output:/app/output --gpus all narco_script:latest --input_path img-path.nii.gz --is_cropped --is_nifti
docker run --rm -v ./input:/app/input -v ./output:/app/output --gpus all narco_script:latest --input_path img-path.nii.gz --is_cropped --is_nifti --threshold 0.5
docker run --rm -v ./input:/app/input -v ./output:/app/output --gpus all narco_script:latest --input_path img-path.nii.gz --is_nifti
docker run --rm -v ./input:/app/input -v ./output:/app/output --gpus all narco_script:latest --input_path dicom-path.zip
The output reports are in output/output.txt
and output/output.json
.
Download the samples from the Inference on samples data
and put them in the input
directory, then run the following:
docker run --rm -v ./input:/app/input -v ./output:/app/output --gpus all narco_script:latest --input_path samples/normal/10064059/img.nii.gz --is_nifti
docker run --rm -v ./input:/app/input -v ./output:/app/output --gpus all narco_script:latest --input_path samples/narco/11943667/img.nii.gz --is_nifti
docker run --rm -v ./input:/app/input -v ./output:/app/output --gpus all narco_script:latest --input_path samples/narco/12017913/img.nii.gz --is_nifti
docker run --rm -v ./input:/app/input -v ./output:/app/output --gpus all narco_script:latest --input_path samples/narco/12065293/img.nii.gz --is_nifti
docker run --rm -v ./input:/app/input -v ./output:/app/output --gpus all narco_script:latest --input_path samples/narco/12076929/img.nii.gz --is_nifti
Expected Outputs:
Note: The range is from 0 to 100.
10064059: {"anomaly": 0.0, "risk": 0, "origin": 0, "report": "No coronary anomalies(AAOCA) have been detected."}
11943667: {"anomaly": 59.41, "risk": 0.0, "origin": 0.84, "report": "R-AAOCA has been detected with anatomical low-risk features."}
12017913: {"anomaly": 100.0, "risk": 100.0, "origin": 0.49, "report": "R-AAOCA has been detected with anatomical high-risk features."}
12065293: {"anomaly": 100.0, "risk": 99.99, "origin": 0.07, "report": "R-AAOCA has been detected with anatomical high-risk features."}
12076929: {"anomaly": 82.36, "risk": 0.0, "origin": 100.0, "report": "L-AAOCA has been detected with anatomical low-risk features."}
The report.txt is like the following:
############################################################################################################################
########################################## Model Outputs for threshold: 70 ##########################################
| Anomaly Detection | Origin Classification |Anatomical Risk Classification
Probability | 82.36 | 100.0 | 0.0
Final Results | AAOCA | L-AAOCA | Low Risk
############################################################################################################################
################################################## Final Diagnosis Report ##################################################
R-AAOCA has been detected with anatomical low-risk features.
############################################################################################################################
docker save narco_script:latest -o narco_script.tar
docker load -i narco_script.tar
For large files, increase the shared memory size of the docker container if you face any sudden docker failure or Core Dump Error.
Note: The default shared memory size is 64MB.
docker run --rm --shm-size 128MB -v ./input:/app/input -v ./output:/app/output --gpus all narco_script:latest --input_path samples/normal/10064059/img.nii.gz --is_nifti