def test_loader(): nn_input_shape = (32, ) * 3 norm_patch_shape = (32, ) * 3 preprocessors = [ AugmentFPRCandidates( candidates_csv="candidates_V2", tags=["luna:3d"], output_shape=nn_input_shape, norm_patch_shape=norm_patch_shape, augmentation_params={ "scale": [1, 1, 1], # factor "uniform scale": 1, # factor "rotation": [0, 0, 0], # degrees "shear": [0, 0, 0], # deg "translation": [0, 0, 0], # mm "reflection": [0, 0, 0] }, # Bernoulli p interp_order=1), DefaultNormalizer(tags=["luna:3d"]) ] l = LunaDataLoader(only_positive=True, multiprocess=False, sets=TRAINING, preprocessors=preprocessors) l.prepare() chunk_size = 1 batches = l.generate_batch(chunk_size=chunk_size, required_input={ "luna:3d": (chunk_size, ) + nn_input_shape, "luna:pixelspacing": (chunk_size, 3) }, required_output={"luna:target": (chunk_size, )}) for sample in batches: import utils.plt print sample[INPUT]["luna:3d"].shape, sample[OUTPUT][ "luna:target"], sample[INPUT]["luna:pixelspacing"] utils.plt.show_animate(np.clip(sample[INPUT]["luna:3d"][0] + 0.25, 0, 1), 50, normalize=False)
##################### training_data = LunaDataLoader(sets=TRAINING, epochs=1, preprocessors=preprocessors, multiprocess=False, crash_on_exception=True) chunk_size = 1 training_data.prepare() if True: print training_data.number_of_samples batches = training_data.generate_batch( chunk_size=chunk_size, required_input={}, required_output={"luna:segmentation": None}, ) # import matplotlib.pyplot as plt import numpy as np import utils.buffering i = 0 np.set_printoptions(formatter={'float_kind': lambda x: "%.1f" % x}) positive_pixels = 0 zero_pixels = 0 for data in batches: i += 1
epochs=1, preprocessors=preprocessors, multiprocess=False, crash_on_exception=True) chunk_size = 1 training_data.prepare() if False: print training_data.number_of_samples batches = training_data.generate_batch( chunk_size=chunk_size, required_input={ "luna:shape": (chunk_size, 3), "luna:pixelspacing": (chunk_size, 3) }, #"luna:3d":(chunk_size,512,512,512), required_output=dict( ) #{"luna:segmentation":None, "luna:sample_id":None}, ) # import matplotlib.pyplot as plt import numpy as np import utils.buffering maximum_pixels = np.zeros(shape=(3, )) maximum_mm = np.zeros(shape=(3, )) i = 0 np.set_printoptions(formatter={'float_kind': lambda x: "%.1f" % x})