def __init__(self, args):
     super().__init__()
     self.args = args
     self.train_imgs = []
     self.train_lbls = []
     self.val_imgs = []
     self.val_lbls = []
     self.test_imgs = []
     self.kfold = KFold(n_splits=self.args.nfolds,
                        shuffle=True,
                        random_state=12345)
     self.data_path = get_path(args)
     configs = get_config_file(self.args)
     self.kwargs = {
         "dim": self.args.dim,
         "patch_size": configs["patch_size"],
         "seed": self.args.seed,
         "gpus": self.args.gpus,
         "num_workers": self.args.num_workers,
         "oversampling": self.args.oversampling,
         "benchmark": self.args.benchmark,
         "nvol": self.args.nvol,
         "train_batches": self.args.train_batches,
         "test_batches": self.args.test_batches,
         "meta": load_data(self.data_path, "*_meta.npy"),
     }
    def get_unet_params(self):
        config = get_config_file(self.args)
        in_channels = config["in_channels"]
        patch_size = config["patch_size"]
        spacings = config["spacings"]
        n_class = config["n_class"]

        strides, kernels, sizes = [], [], patch_size[:]
        while True:
            spacing_ratio = [spacing / min(spacings) for spacing in spacings]
            stride = [
                2 if ratio <= 2 and size >= 8 else 1
                for (ratio, size) in zip(spacing_ratio, sizes)
            ]
            kernel = [3 if ratio <= 2 else 1 for ratio in spacing_ratio]
            if all(s == 1 for s in stride):
                break
            sizes = [i / j for i, j in zip(sizes, stride)]
            spacings = [i * j for i, j in zip(spacings, stride)]
            kernels.append(kernel)
            strides.append(stride)
            if len(strides) == 5:
                break
        strides.insert(0, len(spacings) * [1])
        kernels.append(len(spacings) * [3])

        return in_channels, n_class, kernels, strides, patch_size
예제 #3
0
 def __init__(self, args):
     super().__init__()
     self.args = args
     self.tfrecords_train = []
     self.tfrecords_val = []
     self.tfrecords_test = []
     self.train_idx = []
     self.val_idx = []
     self.test_idx = []
     self.kfold = KFold(n_splits=self.args.nfolds,
                        shuffle=True,
                        random_state=12345)
     self.data_path = os.path.join(self.args.data, get_task_code(self.args))
     if self.args.exec_mode == "predict" and not args.benchmark:
         self.data_path = os.path.join(self.data_path, "test")
     configs = get_config_file(self.args)
     self.kwargs = {
         "dim": self.args.dim,
         "patch_size": configs["patch_size"],
         "seed": self.args.seed,
         "gpus": self.args.gpus,
         "num_workers": self.args.num_workers,
         "oversampling": self.args.oversampling,
         "create_idx": self.args.create_idx,
         "benchmark": self.args.benchmark,
     }
예제 #4
0
 def __init__(self, args):
     super().__init__()
     self.args = args
     self.data_path = get_data_path(args)
     self.kfold = get_kfold_splitter(args.nfolds)
     self.kwargs = {
         "dim": self.args.dim,
         "seed": self.args.seed,
         "gpus": self.args.gpus,
         "nvol": self.args.nvol,
         "overlap": self.args.overlap,
         "benchmark": self.args.benchmark,
         "num_workers": self.args.num_workers,
         "oversampling": self.args.oversampling,
         "test_batches": self.args.test_batches,
         "train_batches": self.args.train_batches,
         "invert_resampled_y": self.args.invert_resampled_y,
         "patch_size": get_config_file(self.args)["patch_size"],
     }
     self.train_imgs, self.train_lbls, self.val_imgs, self.val_lbls, self.test_imgs = (
         [], ) * 5
예제 #5
0
    def __init__(self, args):
        super().__init__()
        self.args = args
        self.train_imgs = []
        self.train_lbls = []
        self.val_imgs = []
        self.val_lbls = []
        self.test_imgs = []
        self.kfold = KFold(n_splits=self.args.nfolds,
                           shuffle=True,
                           random_state=12345)
        self.data_path = get_path(args)
        configs = get_config_file(self.args)

        if self.args.gpus:
            device_count = self.args.gpus
            device = 'gpu'
        elif self.args.hpus:
            device_count = self.args.hpus
            device = 'hpu'
        else:
            device_count = 1
            device = 'cpu'

        self.kwargs = {
            "dim": self.args.dim,
            "patch_size": configs["patch_size"],
            "seed": self.args.seed,
            "num_device": device_count,
            "num_workers": self.args.num_workers,
            "oversampling": self.args.oversampling,
            "benchmark": self.args.benchmark,
            "nvol": self.args.nvol,
            "train_batches": self.args.train_batches,
            "test_batches": self.args.test_batches,
            "meta": load_data(self.data_path, "*_meta.npy"),
            "device": device,
            "augment": self.args.augment,
            "set_aug_seed": self.args.set_aug_seed,
        }