class testUtils(unittest.TestCase): "test class for the DataProvider module" def setUp(self): self.data_provider = DataProvider() self.number = 2 def test_datasets(self): attrs = dict(size=1, files=2) datasets = self.data_provider.datasets(self.number, **attrs) print "\ndatasets:\n", datasets self.assertEqual(self.number, len(datasets)) def test_blocks(self): attrs = {'is-open':'y'} blocks = self.data_provider.blocks(self.number, **attrs) print "\nblocks:\n", blocks self.assertEqual(self.number, len(blocks)) def test_files(self): attrs = dict(adler32='abcd') files = self.data_provider.files(self.number, **attrs) print "\nfiles:\n", files self.assertEqual(self.number, len(files)) def test_lumis(self): attrs = {} lumis = self.data_provider.lumis(self.number, **attrs) print "\nlumis:\n", lumis self.assertEqual(self.number, len(lumis))
valid_set = fold1_list.copy() test_set = np.load(data_path + '/whole_data/validation_file.npy').tolist().copy() org_suffix = '_orig.nii.gz' lab_suffix = '_multiclass_pve.nii.gz' pre = { org_suffix: [('channelcheck', 1)], lab_suffix: [('one-hot', 5), ('channelcheck', 5)] } processor = SimpleImageProcessor(pre=pre) train_provider = DataProvider(train_set, [org_suffix, lab_suffix], is_pre_load=False, processor=processor) validation_provider = DataProvider(valid_set, [org_suffix, lab_suffix], is_pre_load=False, processor=processor) u_net = UNet3D(n_class=5, n_layer=4, root_filters=16, use_bn=True) model = SimpleTFModel(u_net, org_suffix, lab_suffix, dropout=0, loss_function={'cross-entropy': 1.}, weight_function={'balance'}) optimizer = tf.keras.optimizers.Adam(args.learning_rate)
def setUp(self): self.data_provider = DataProvider() self.number = 2
train_list = file_mat['train_set'] valid_list = file_mat['validation_set'] test_list = file_mat['test_set'] # add path to filename org_suffix = '.nii.gz' age_suffix = '_lab.txt' pre = {org_suffix: [('zero-mean'), ('min-max'), ('channelcheck', 1)]} # processor = Processor() processor = SimpleImageProcessor(pre=pre) train_provider = DataProvider( train_list, [org_suffix, age_suffix], is_pre_load=False, is_shuffle=True, # temp_dir=output_path, processor=processor) valid_provider = DataProvider( valid_list, [org_suffix, age_suffix], is_pre_load=False, # temp_dir=output_path, processor=processor) # build model gen = Generator(output_channels=1, use_bn=use_bn) disc = Discriminator(use_bn=use_bn) # gen = Generator(n_class=1, n_layer=6, root_filters=16, use_bn=use_bn, use_res=use_res)
def get_phonebook_name(data_provider: DataProvider) -> Union[str, None]: if Validator.check_arguments(data_provider): return data_provider.get_argument() return None
def get_data(self): """ Get data to show in the view; format depends on the type """ dp = DataProvider( ) # could use the Todoist API directly, this is a bit for the future; to support weird data formats return {} # wx2 NotImplementedError on get data for view
def __init__(self, type): if type not in self.SUPPORTED_TYPES: pass # wx3: type validation: without valid type we shouldn't init self.type = type self.dp = DataProvider()