# In[11]: from Augmentor import Pipeline # In[12]: augmentor = Pipeline('/home/asherif844/sparkNotebooks/Ch03/MNIST/images') # In[13]: augmentor.rotate(probability=0.9, max_left_rotation=25, max_right_rotation=25) # In[14]: for i in range(1, 3): augmentor.sample(10) # In[15]: xtrain = data.train.images ytrain = np.asarray(data.train.labels) xtest = data.test.images ytest = np.asarray(data.test.labels) # In[16]: xtrain = xtrain.reshape(xtrain.shape[0], 28, 28, 1) xtest = xtest.reshape(xtest.shape[0], 28, 28, 1) ytest = ytest.reshape(ytest.shape[0], 10) ytrain = ytrain.reshape(ytrain.shape[0], 10)
# p.flip_top_bottom(probability=0.5) # # # 随机90, 180, 270 度旋转 # p.rotate_random_90(probability=0.75) # # # 随机20度内旋转,不变形, 四角填充黑色,图片大小不变 # p.rotate_without_crop(probability=0.5, max_left_rotation=20, max_right_rotation=20) # # # 随机20度内旋转,不变形, 四角填充黑色,图片大小调整 # p.rotate_without_crop(probability=0.5, max_left_rotation=20, max_right_rotation=20, expand=True) # # # 随机剪切, 中心不变 # p.crop_by_size(probability=0.5, width=100, height=100) # # # 随机剪切,中心变化,可调节剪切比例 # p.crop_random(probability=0.5, percentage_area=0.8) # # # 随机20%缩放,大小不变,图片缩小时以黑色填充 # p.zoom(probability=0.5, min_factor=0.8, max_factor=1.2) # resize p.resize(probability=1, width=256, height=256) # execute and sample from the pipeline time1 = time.time() num_of_samples = 14200 p.sample(num_of_samples) time2 = time.time() print("time cost = " + str(time2 - time1) + "s")