print("Number of images: {}".format(len(X))) # start = time() # result = data.batch_perturb_and_augment(X, 500, 500, aug_params=aug_params, sigma=0.5) # end = time() # print("Processing without parallelization took {} seconds".format(end - start)) #start = time() #result = data.parallel_perturb_and_augment(X, 500, 500, aug_params=aug_params, sigma=0.5) #result = data.parallel_perturb_and_augment(X, 500, 500) #end = time() #print("Processing with parallelization took {} seconds".format(end - start)) start = time() result = data_util.parallel_augment(X) end = time() print("Processing with parallelization (different version) took {} seconds". format(end - start)) original_image = X[12] original_image = original_image.transpose(1, 2, 0) augmented_image = result[12] augmented_image = augmented_image.transpose(1, 2, 0) fig = plt.figure() a = fig.add_subplot(1, 2, 1) plt.imshow(original_image) a.set_title('Before') a = fig.add_subplot(1, 2, 2)
files = data_util.get_image_files(DATA_DIR) images = data_util.load_images(files) MEAN = data_util.compute_mean(files) STD = data_util.compute_std(files) images_normalized = [] for img in images: img = img - MEAN[:, np.newaxis, np.newaxis] img = img / STD[:, np.newaxis, np.newaxis] images_normalized.append(img) images_normalized = np.array(images_normalized) original_augmented = data_util.parallel_augment(images) normalized_augmented = data_util.parallel_augment(images_normalized) original = images[3] normalized = images_normalized[3] original = original.transpose(1, 2, 0) normalized = normalized.transpose(1, 2, 0) oa = original_augmented[3] oa = oa.transpose(1, 2, 0) na = normalized_augmented[3] na = na.transpose(1, 2, 0) fig = plt.figure() a = fig.add_subplot(2, 2, 1) plt.imshow(original) a.set_title('original')