-
-
Notifications
You must be signed in to change notification settings - Fork 149
Integration with SCT
Naga Karthik edited this page Jan 9, 2023
·
1 revision
This document describes the process of how the deep learning (DL) models trained with ivadomed are integrated into SCT.
Step 1 (on the ivadomed
side)
- After training a model using
ivadomed
, a folder defined bymodel_name
used in the config file can be found in the results folder. The contents of this folder are: (i) A.json
file, i.e. the config file used for training the model, (ii) A.onnx
file that stores the trained model in the system-agnostic (onnx) format, and (iii) A.pt
file that stores the trained model in pytorch's typical model-saving format.- The
.onnx
model and the.json
file have to be zipped and uploaded to the GitHub release that provides the latest model (to be packaged into SCT). The url that the release provides will be used in Step 2. - NOTE: A GitHub release has to be created in the project repository in order to complete the above step.
- The
Step 2 (on the SCT
side)
- In order for this model to be used by SCT users, an entry in the same format as described in this file has to be made. This has to be done for both
MODELS
andTASKS
dicitionaries. For example, an entry in theMODELS
dict looks like (note how in theurl
the zipped package in Step 1 is linked):
"model_seg_ms_lesion_mp2rage": {
"url": [
"https://github.com/ivadomed/model_seg_ms_mp2rage/releases/download/r20211223/model_seg_ms_lesion_mp2rage.zip"
],
"description": "Segmentation of multiple sclerosis lesions on cropped MP2RAGE spinal cord data. To crop the "
"data you can first segment the spinal cord using the model 'model_seg_ms_sc_mp2rage' and "
"then crop the MP2RAGE image using 'sct_crop_image -i IMAGE -m IMAGE_seg'",
"contrasts": ["mp2rage"],
"default": False,
},
- NOTE: These changes have to first be approved by a SCT developer through a Pull Request (PR) in the SCT's repository.
- Once the PR has been approved:
- All the available models can be viewed using the following command
sct_deepseg -list-tasks
. - The (new) model can be downloaded and extracted using
sct_deepseg -install-task <model-name>
- Then, inference can be run using this model from this command
sct_deepseg -i img.nii.gz -task <task_name>
. Note, the task name is the same name that is in theTASKS
dict in thespinalcordtoolbox/deepseg/models.py
file.
- All the available models can be viewed using the following command
Step 3 (behind-the-scenes)
Whenever we use sct_deepseg
, it internally calls the ivadomed.inference.segment_volume
function that essentially uses the downloaded (trained) model and segments the input image based on the given task.
Summary
In conclusion, ivadomed's integration into SCT is just:
- Hosting a model online, and
- Adding it to
sct_deepseg
, from which it can then be downloaded and used.