Beispiel #1
0
def wrap_dataloader(dl):
    dl = OneHot(dl, index=1, nclasses=10)
    dl = TypeCast(dl, index=0, dtype=np.float32)
    dl = ValueNormalize(dl,
                        index=0,
                        source_range=[0., 255.],
                        target_range=[-1., 1.])
    return dl
Beispiel #2
0
def make_test_loader(manifest_file,
                     manifest_root,
                     backend_obj,
                     subset_pct=100):
    aeon_config = common_config(manifest_file, manifest_root, backend_obj.bsz)
    aeon_config['subset_fraction'] = float(subset_pct / 100.0)
    dl = AeonDataLoader(aeon_config, backend_obj)
    dl = OneHot(dl, index=1, nclasses=101)
    dl = TypeCast(dl, index=0, dtype=np.float32)
    return dl
Beispiel #3
0
def make_train_loader(manifest_file,
                      manifest_root,
                      backend_obj,
                      subset_pct=100,
                      random_seed=0):
    aeon_config = common_config(manifest_file, manifest_root, backend_obj.bsz)
    aeon_config['subset_fraction'] = float(subset_pct / 100.0)
    aeon_config['shuffle_manifest'] = True
    aeon_config['shuffle_every_epoch'] = True
    aeon_config['random_seed'] = random_seed

    aeon_config['video']['frame']['center'] = False
    aeon_config['video']['frame']['flip_enable'] = True

    dl = AeonDataLoader(aeon_config, backend_obj)
    dl = OneHot(dl, index=1, nclasses=101)
    dl = TypeCast(dl, index=0, dtype=np.float32)
    return dl
Beispiel #4
0
def wrap_dataloader(dl):
    dl = OneHot(dl, index=1, nclasses=2)
    dl = TypeCast(dl, index=0, dtype=np.float32)
    return dl
Beispiel #5
0
def transformers(dl):
    dl = OneHot(dl, nclasses=10, index=1)
    dl = TypeCast(dl, index=0, dtype=np.float32)
    dl = BGRMeanSubtract(dl, index=0, pixel_mean=bgr_means)
    return dl
Beispiel #6
0
def wrap_dataloader(dl):
    dl = OneHot(dl, index=1, nclasses=10)
    dl = TypeCast(dl, index=0, dtype=np.float32)
    dl = BGRMeanSubtract(dl, index=0)
    return dl
Beispiel #7
0
def wrap_dataloader(aeon_config):
    dl = AeonDataLoader(aeon_config)
    dl = OneHot(dl, index=1, nclasses=101)
    dl = TypeCast(dl, index=0, dtype=np.float32)
    return dl
Beispiel #8
0
# Set up the training set to load via aeon
# Augmentating the data via flipping, rotating, changing contrast/brightness
image_config = dict(height=64, width=64, flip_enable=True, channels=1,
                    contrast=(0.5,1.0), brightness=(0.5,1.0), 
                    scale=(0.7,1), fixed_aspect_ratio=True)
label_config = dict(binary=False)
config = dict(type="image,label",
              image=image_config,
              label=label_config,
              manifest_filename='manifest_all_but_9.csv',
              minibatch_size=args.batch_size,
              shuffle_every_epoch = True)
train_set = DataLoader(config, be)
train_set = TypeCast(train_set, index=0, dtype=np.float32)  # cast image to float
train_set = OneHot(train_set, index=1, nclasses=2)

# Set up the validation set to load via aeon
image_config = dict(height=64, width=64, channels=1)
label_config = dict(binary=False)
config = dict(type="image,label",
              image=image_config,
              label=label_config,
              manifest_filename='manifest_subset9_augmented.csv',
              minibatch_size=args.batch_size)
valid_set = DataLoader(config, be)
valid_set = TypeCast(valid_set, index=0, dtype=np.float32)  # cast image to float
valid_set = OneHot(valid_set, index=1, nclasses=2)

# Set up the testset to load via aeon
image_config = dict(height=64, width=64, channels=1)
print('Batch size = {}'.format(args.batch_size))

# setup backend
be = gen_backend(**extract_valid_args(args, gen_backend))

# Set up the testset to load via aeon
image_config = dict(height=64, width=64, channels=1)
label_config = dict(binary=False)
config = dict(type="image,label",
              image=image_config,
              label=label_config,
              manifest_filename=testFileName,
              minibatch_size=args.batch_size,
              subset_fraction=1)
test_set = DataLoader(config, be)
test_set = TypeCast(test_set, index=0, dtype=np.float32)  # cast image to float
test_set = OneHot(test_set, index=1, nclasses=2)

lunaModel = Model('LUNA16_VGG_model_no_batch.prm')

pred, target = lunaModel.get_outputs(test_set, return_targets=True) # Reshape to a single prediction vector
pred = pred.T
target = target.T

np.set_printoptions(precision=3, suppress=True)
print(' ')
print(pred)
print(target)