示例#1
0
def test_object_detection(train_lst, target_lst, config):
    # Load config file
    context = imed_config_manager.ConfigurationManager("testing_data/model_config.json").get_config()
    context.update(config)

    command = "ivadomed_download_data -d findcord_tumor"
    subprocess.check_output(command, shell=True)

    imed.run_command(context)
示例#2
0
def test_object_detection(train_lst, target_lst, config):
    # Load config file
    with open("testing_data/model_config.json", 'r') as fp:
        context = json.load(fp)
    context.update(config)

    command = "ivadomed_download_data -d findcord_tumor"
    subprocess.check_output(command, shell=True)

    imed.run_command(context)
示例#3
0
def train_worker(config, thr_incr):
    current = mp.current_process()
    # ID of process used to assign a GPU
    ID = int(current.name[-1]) - 1

    # Use GPU i from the array specified in the config file
    config["gpu"] = config["gpu"][ID]

    # Call ivado cmd_train
    try:
        # Save best validation score
        best_training_dice, best_training_loss, best_validation_dice, best_validation_loss = \
            ivado.run_command(config, thr_increment=thr_incr)

    except:
        logging.exception('Got exception on main handler')
        print("Unexpected error:", sys.exc_info()[0])
        raise

    # Save config file in log directory
    config_copy = open(config["log_directory"] + "/config_file.json", "w")
    json.dump(config, config_copy, indent=4)

    return config[
        "log_directory"], best_training_dice, best_training_loss, best_validation_dice, best_validation_loss
示例#4
0
def train_worker(config, thr_incr):
    """
    Args:
        config (dict): dictionary containing configuration details.
        thr_incr (float): A threshold analysis is performed at the end of the training
            using the trained model and the validation sub-dataset to find the optimal binarization
            threshold. The specified value indicates the increment between 0 and 1 used during the
            ROC analysis (e.g. 0.1). Flag: ``-t``, ``--thr-increment``
    """
    current = mp.current_process()
    # ID of process used to assign a GPU
    ID = int(current.name[-1]) - 1

    # Use GPU i from the array specified in the config file
    config["gpu_ids"] = [config["gpu_ids"][ID]]

    # Call ivado cmd_train
    try:
        # Save best validation score
        config["command"] = "train"
        best_training_dice, best_training_loss, best_validation_dice, best_validation_loss = \
            ivado.run_command(config, thr_increment=thr_incr)

    except Exception:
        logging.exception('Got exception on main handler')
        logging.info("Unexpected error:", sys.exc_info()[0])
        raise

    # Save config file in output path
    config_copy = open(config["path_output"] + "/config_file.json", "w")
    json.dump(config, config_copy, indent=4)

    return config["path_output"], best_training_dice, best_training_loss, best_validation_dice, \
        best_validation_loss
def get_results(context):
    context["command"] = "test"
    pred_mask_path = os.path.join(context["path_output"], "pred_masks")
    if os.path.exists(pred_mask_path):
        shutil.rmtree(pred_mask_path)

    # RandomAffine will be applied during testing
    if "dataset_type" in context["transformation"]["RandomAffine"]:
        del context["transformation"]["RandomAffine"]["dataset_type"]
    if "scale" in context["transformation"]["RandomAffine"]:
        del context["transformation"]["RandomAffine"]["scale"]
    return ivado.run_command(context)
def test_worker(config):
    # Call ivado cmd_eval

    current = mp.current_process()
    # ID of process used to assign a GPU
    ID = int(current.name[-1]) - 1

    # Use GPU i from the array specified in the config file
    config["gpu"] = config["gpu"][ID]

    try:
        # Save best test score
        config["command"] = "test"
        df_results, test_dice = ivado.run_command(config)

    except:
        logging.exception('Got exception on main handler')
        print("Unexpected error:", sys.exc_info()[0])
        raise

    return config["log_directory"], test_dice, df_results
def test_worker(config):
    # Call ivado cmd_eval

    current = mp.current_process()
    # ID of process used to assign a GPU
    ID = int(current.name[-1]) - 1

    # Use GPU i from the array specified in the config file
    config[ConfigKW.GPU_IDS] = [config[ConfigKW.GPU_IDS][ID]]

    try:
        # Save best test score
        config[ConfigKW.COMMAND] = "test"
        df_results, test_dice = ivado.run_command(config)

    except Exception:
        logger.exception('Got exception on main handler')
        logger.info("Unexpected error:", sys.exc_info()[0])
        raise

    return config[ConfigKW.PATH_OUTPUT], test_dice, df_results