コード例 #1
0
        # 'offset': (8, 20, 20),
        'out_channels': 2,
        # 'in_memory': True  # Uncomment to avoid disk I/O (if you have enough host memory for the data)
    }
    norm_mean = (155.291411, )
    norm_std = (42.599973, )
    valid_transform = transforms.Normalize(mean=norm_mean,
                                           std=norm_std,
                                           inplace=True)

    print('Loading dataset...')
    valid_dataset = PatchCreator(
        input_sources=input_h5data,
        target_sources=target_h5data,
        train=False,
        epoch_size=40,  # How many samples to use for each validation run
        warp_prob=0,
        warp_kwargs={'sample_aniso': aniso_factor != 1},
        transform=valid_transform,
        **common_data_kwargs)
    valid_loader = DataLoader(valid_dataset, num_workers=4, pin_memory=True)

    # Validation metrics
    valid_metrics = {  # mean metrics
        'val_accuracy_mean': metrics.Accuracy(),
        'val_precision_mean': metrics.Precision(),
        'val_recall_mean': metrics.Recall(),
        'val_DSC_mean': metrics.DSC(),
        'val_IoU_mean': metrics.IoU(),
    }
    if valid_dataset.out_channels > 2:
コード例 #2
0
aniso_factor = 2  # Anisotropy in z dimension. E.g. 2 means half resolution in z dimension.
common_data_kwargs = {  # Common options for training and valid sets.
    'aniso_factor': aniso_factor,
    'patch_shape': (44, 88, 88),
    # 'offset': (8, 20, 20),
    # 'in_memory': True  # Uncomment to avoid disk I/O (if you have enough host memory for the data)
}
train_dataset = PatchCreator(input_sources=[
    input_h5data[i] for i in range(len(input_h5data)) if i not in valid_indices
],
                             target_sources=[
                                 target_h5data[i]
                                 for i in range(len(input_h5data))
                                 if i not in valid_indices
                             ],
                             train=True,
                             epoch_size=args.epoch_size,
                             warp_prob=0.2,
                             warp_kwargs={
                                 'sample_aniso': aniso_factor != 1,
                                 'perspective': True,
                                 'warp_amount': 1.0,
                             },
                             transform=train_transform,
                             **common_data_kwargs)
valid_dataset = None if not valid_indices else PatchCreator(
    input_sources=[
        input_h5data[i] for i in range(len(input_h5data)) if i in valid_indices
    ],
    target_sources=[
        target_h5data[i] for i in range(len(input_h5data))
        if i in valid_indices
コード例 #3
0
ファイル: train_noise2void.py プロジェクト: flmuk/elektronn3
    from elektronn3.data.knossos import KnossosRawData

    train_dataset = KnossosRawData(
        conf_path=
        '/wholebrain/songbird/j0126/areaxfs_v5/knossosdatasets/mag1/knossos.conf',
        patch_shape=common_data_kwargs['patch_shape'],
        transform=train_transform,
        epoch_size=args.epoch_size,
        mode='caching',
    )
else:
    train_dataset = PatchCreator(input_sources=[
        input_h5data[i] for i in range(len(input_h5data))
        if i not in valid_indices
    ],
                                 train=True,
                                 epoch_size=args.epoch_size,
                                 warp_prob=0,
                                 transform=train_transform,
                                 **common_data_kwargs)

valid_dataset = PatchCreator(input_sources=[
    input_h5data[i] for i in range(len(input_h5data)) if i in valid_indices
],
                             train=False,
                             epoch_size=args.epoch_size,
                             warp_prob=0,
                             transform=valid_transform,
                             **common_data_kwargs)

# Use first validation cube for previews. Can be set to any other data source.
コード例 #4
0
    'num_classes': 6,
    # 'offset': (20, 46, 46),
    'target_discrete_ix': [3, 4, 5]
}

type_args = list(range(len(input_h5data)))
train_dataset = PatchCreator(input_h5data=[
    input_h5data[i] for i in type_args if i not in valid_indices
],
                             target_h5data=[
                                 target_h5data[i] for i in type_args
                                 if i not in valid_indices
                             ],
                             train=True,
                             epoch_size=args.epoch_size,
                             cube_prios=None,
                             warp_prob=0.2,
                             in_memory=True,
                             warp_kwargs={
                                 'sample_aniso': aniso_factor != 1,
                                 'perspective': True,
                                 'warp_amount': 0.05,
                             },
                             transform=train_transform,
                             **common_data_kwargs)
valid_dataset = None if (valid_indices is None) or (
    len(valid_indices) == 0) else PatchCreator(
        input_h5data=[
            input_h5data[i] for i in range(len(input_h5data))
            if i in valid_indices
        ],
コード例 #5
0
    ])
    valid_transform = transforms.Compose(common_transforms + [])

    # Specify data set
    common_data_kwargs = {  # Common options for training and valid sets.
        'aniso_factor': 2,
        'patch_shape': (48, 96, 96),
        'classes': [0, 1],
    }
    train_dataset = PatchCreator(
        input_h5data=input_h5data[:2],
        target_h5data=target_h5data[:2],
        train=True,
        epoch_size=args.epoch_size,

        warp=0.5,
        warp_kwargs={
            'sample_aniso': True,
            'perspective': True,
        },
        transform=train_transform,**common_data_kwargs
    )
    valid_dataset = PatchCreator(
        input_h5data=[input_h5data[2]],
        target_h5data=[target_h5data[2]],
        train=False,
        epoch_size=10,  # How many samples to use for each validation run
        preview_shape=(64, 144, 144),
        warp=0,
        warp_kwargs={
            'sample_aniso': True,