Beispiel #1
0
def fbpunet_reconstructor(dataset='ellipses',
                          size_part=1.0,
                          pretrained=True,
                          name=None):
    """
    :param dataset: Can be 'ellipses' or 'lodopab'
    :param size_part: Can be one of: [0.001, 0.002, 0.005, 0.01, 0.02, 0.05,
                      0.1, 0.2, 0.5, 1.0]
    :return: The FBP+UNet method trained on the specified dataset and size
    """
    try:
        standard_dataset = load_standard_dataset(dataset)
        params = Params.load('{}_fbpunet_{}'.format(dataset, size_part))
        if name is None:
            name = 'FBP+UNet ({} $\%$)'.format(100 * size_part)

        reconstructor = FBPUNetReconstructor(standard_dataset.ray_trafo,
                                             hyper_params=params.dict,
                                             name=name)
        if pretrained:
            load_weights(reconstructor,
                         '{}_fbpunet_{}'.format(dataset, size_part))
        return reconstructor
    except Exception as e:
        raise Exception(
            'The reconstructor does not exist for the selected data_size')
Beispiel #2
0
def iradonmap_reconstructor(dataset='ellipses',
                            size_part=1.0,
                            pretrained=True,
                            name=None):
    """
    :param dataset: Can be 'ellipses' or 'lodopab'
    :param size_part: Can be one of: [0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0]
    :return: The iRadonMap method trained on the specified dataset and size
    """
    try:
        standard_dataset = load_standard_dataset(dataset)
        params = Params.load('{}_iradonmap_{}'.format(dataset, size_part))
        if name is None:
            name = 'iRadonMap ({} $\%$)'.format(100 * size_part)
        coord_mat = None
        try:
            coord_mat = np.load(
                os.path.join(BASE_DIR, 'reconstructors',
                             '{}_iradonmap_coord_mat.npy'.format(dataset)))
        except FileNotFoundError:
            pass
        reconstructor = IRadonMapReconstructor(standard_dataset.ray_trafo,
                                               hyper_params=params.dict,
                                               name=name,
                                               coord_mat=coord_mat)
        if pretrained:
            load_weights(reconstructor,
                         '{}_iradonmap_{}'.format(dataset, size_part))
        return reconstructor
    except Exception as e:
        raise Exception(
            'The reconstructor has not been trained with the selected data_size'
        )
Beispiel #3
0
def learnedpd_dip_reconstructor(dataset='ellipses', size_part=1.0, name=None):
    """
    :param dataset: Can be 'ellipses' or 'lodopab'
    :return: The Deep Image Prior (DIP) method for the specified dataset
    """
    try:
        standard_dataset = load_standard_dataset(dataset)
        params = Params.load('{}_learnedpd_{}'.format(dataset, size_part))
        learned_pd = LearnedPDReconstructor(standard_dataset.ray_trafo,
                                            hyper_params=params.dict,
                                            name='Learned PD ({}%)'.format(
                                                size_part * 100))
        load_weights(learned_pd, '{}_learnedpd_{}'.format(dataset, size_part))

        # load hyper-parameters and create reconstructor
        if name is None:
            name = 'Learned PD ({} $\%$) + DIP'.format(100 * size_part)
        params = Params.load('{}_learnedpd_dip_{}'.format(dataset, size_part))
        reconstructor = DeepImagePriorInitialReconstructor(
            standard_dataset.ray_trafo,
            ini_reco=learned_pd,
            hyper_params=params.dict,
            name=name)
        return reconstructor
    except Exception as e:
        raise Exception('The reconstructor doesn\'t exist')
Beispiel #4
0
def learnedgd_reconstructor(dataset='ellipses',
                            size_part=1.0,
                            pretrained=True,
                            name=None):
    """
    :param dataset: Can be 'ellipses' or 'lodopab'
    :param size_part: Can be one of: [0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0]
    :return: The Learned Gradient Descent method trained on the specified dataset and size
    """
    try:
        standard_dataset = load_standard_dataset(dataset)
        params = Params.load('{}_learnedgd_{}'.format(dataset, size_part))
        if name is None:
            name = 'Learned GD ({} $\%$)'.format(100 * size_part)
        reconstructor = LearnedGDReconstructor(standard_dataset.ray_trafo,
                                               hyper_params=params.dict,
                                               name=name)
        if pretrained:
            load_weights(reconstructor,
                         '{}_learnedgd_{}'.format(dataset, size_part))
        return reconstructor
    except Exception as e:
        raise Exception(
            'The reconstructor has not been trained with the selected data_size'
        )