Skip to content

Commit

Permalink
Merge pull request #29 from sarthakpati/master
Browse files Browse the repository at this point in the history
0.0.3 ready
  • Loading branch information
sarthakpati authored Mar 3, 2021
2 parents f2e3576 + e6a4402 commit e3c02a8
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 25 deletions.
22 changes: 11 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SET( ${PROJECT_NAME}_Variant "Full" ) # the particular variant of CaPTk (Full/Ne

SET( PROJECT_VERSION_MAJOR 0 )
SET( PROJECT_VERSION_MINOR 0 )
SET( PROJECT_VERSION_PATCH 3-dev )
SET( PROJECT_VERSION_PATCH 3 )
SET( PROJECT_VERSION_TWEAK )

# check for the string "nonRelease" in the PROJECT_VERSION_PATCH variable
Expand Down Expand Up @@ -596,18 +596,18 @@ IF( NOT BUILD_DOCUMENTATION_ONLY )
ENDIF()
ENDIF()

# SET( DOWNLOAD_LINK "ftp://www.nitrc.org/home/groups/captk/downloads/models/torch/pt_3dresunet_fets_phase1_brats20pretrained_init_1.pbuf" )
# SET( FILE_TO_EXTRACT "${PROJECT_SOURCE_DIR}/OpenFederatedLearning/bin/federations/weights/pt_3dresunet_fets_phase1_brats20pretrained_init_1.pbuf")
SET( DOWNLOAD_LINK "ftp://www.nitrc.org/home/groups/captk/downloads/models/torch/pt_3dresunet_fets_phase1_brats20pretrained_init_1.pbuf" )
SET( FILE_TO_EXTRACT "${PROJECT_SOURCE_DIR}/OpenFederatedLearning/bin/federations/weights/pt_3dresunet_fets_phase1_brats20pretrained_init_1.pbuf")

# IF( NOT EXISTS "${FILE_TO_EXTRACT}" )
IF( NOT EXISTS "${FILE_TO_EXTRACT}" )

# # download exe from url
# MESSAGE( STATUS "Downloading weights for BraTS evaluation model" )
# FILE(DOWNLOAD "${DOWNLOAD_LINK}" "${FILE_TO_EXTRACT}" TIMEOUT 1000000 STATUS STATUS_CODE SHOW_PROGRESS)
# IF(NOT STATUS_CODE EQUAL 0)
# MESSAGE(FATAL_ERROR "Failed to download BraTS evaluation model weights. Status=${STATUS_CODE}")
# ENDIF()
# ENDIF()
# download exe from url
MESSAGE( STATUS "Downloading weights for BraTS evaluation model" )
FILE(DOWNLOAD "${DOWNLOAD_LINK}" "${FILE_TO_EXTRACT}" TIMEOUT 1000000 STATUS STATUS_CODE SHOW_PROGRESS)
IF(NOT STATUS_CODE EQUAL 0)
MESSAGE(FATAL_ERROR "Failed to download BraTS evaluation model weights. Status=${STATUS_CODE}")
ENDIF()
ENDIF()

# copy network information
## todo: change to a direct installation so that git doesn't get confused that submodule has changed
Expand Down
2 changes: 1 addition & 1 deletion OpenFederatedLearning
7 changes: 7 additions & 0 deletions data/cwlFiles/FeTS_CLI.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ inputs:
position: 1
prefix: -cwl
doc: Generates a .cwl file for the software.
trainPlan:
type: boolean?
label: YAML file
inputBinding:
position: 1
prefix: -tp
doc: Training plan.Defaults to 'fets_phase1_1'.
LoggingDir:
type: Directory?
label: Dir with write access
Expand Down
13 changes: 13 additions & 0 deletions docs/runningApplication.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ wget https://raw.githubusercontent.com/FETS-AI/Front-End/master/src/applications

## Training

### Ensure Sanity Checking Is Done

Proceed to training once [sanity check](#sanity-check) is successfully finished.
### Transfer Certificates

If you have a [signed certificate from a previous installation](https://fets-ai.github.io/Front-End/setup#set-up-the-collaborator), ensure they are copied **before** trying to train:
```bash
cd ${fets_root_dir}/bin/
cp -r ${fets_root_dir_old}/bin/OpenFederatedLearning/bin/federations/pki/client ./OpenFederatedLearning/bin/federations/pki
```

### Start Training

```bash
${fets_root_dir}/bin/FeTS_CLI -d /path/to/output/DataForFeTS \ # input data, ensure "final_seg" is present for each subject
-c ${collaborator_common_name} \ # common collaborator name created during setup
Expand Down
35 changes: 22 additions & 13 deletions src/applications/FeTS_CLI.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ int main(int argc, char** argv)
}
else
{
loggingDir = dataDir + "/logs";
loggingDir = cbica::createTemporaryDirectory() + "/logs";
std::cout << "Using the following directory as logging directory: " << loggingDir << "\n";
cbica::createDir(loggingDir);
}

Expand Down Expand Up @@ -398,30 +399,38 @@ int main(int argc, char** argv)
} // end of trainingRequested check
else // for training
{
std::string specialArgs, args, hardcodedModelName;
if (trainingRequested)
{
specialArgs = "-col " + colName;
}

std::string args = " -d " + dataDir + " -ld " + loggingDir + " -col " + colName + device_arg,
hardcodedModelName;

if (!cbica::isFile(hardcodedPythonPath))
{
std::cerr << "The python virtual environment was not found, please refer to documentation to initialize it.\n";
return EXIT_FAILURE;
}

{
std::cout << "Starting model validation of 3DResUNet trained on BraTS20 training data...\n";

// brats20 model validation
std::string fullCommandToRun = hardcodedPythonPath + " " + fetsApplicationPath;
fullCommandToRun += "/OpenFederatedLearning/bin/run_fets_validation.py";

auto temp_args = args + " -p fets_phase1_validate_full_brats_trained_model_1.yaml";

if (std::system((fullCommandToRun + " " + temp_args).c_str()) != 0)
{
std::cerr << "Couldn't complete the BraTS20 model validation task, please email admin@fets.ai\n";
}
}

std::string fullCommandToRun = hardcodedPythonPath + " " + fetsApplicationPath;
fullCommandToRun += "/OpenFederatedLearning/bin/run_collaborator_from_flplan.py";

args += " -p " + hardcodedPlanName + ".yaml"
+ " -d " + dataDir
+ " -ld " + loggingDir;

args += device_arg;
auto temp_args = args + " -p " + hardcodedPlanName + ".yaml";

std::cout << "Starting training...\n";

if (runCollaboratorTraining(fullCommandToRun + " " + args + " " + specialArgs) != 0)
if (runCollaboratorTraining(fullCommandToRun + " " + temp_args) != 0)
{
std::cerr << "Couldn't complete the training task, please email admin@fets.ai\n";
return EXIT_FAILURE;
Expand Down

0 comments on commit e3c02a8

Please sign in to comment.