def augment_with_params(self, Xb, shift_x, shift_y, rotation, random_flip, zoom, hue, saturation, value):
# Define affine matrix
# TODO: Should be able to incorporate flips directly instead of through an extra call
M = cv2.getRotationMatrix2D((self.center_shift[0], self.center_shift[1]), rotation, zoom)
M[0, 2] += shift_x
M[1, 2] += shift_y
augment_partial = partial(augment_image,
M=M,
random_flip=random_flip,
random_hue=hue,
random_saturation=saturation,
random_value=value)
if self.multiprocess:
l = self.pool.map(augment_partial, Xb)
Xbb = np.array(l)
else:
Xbb = np.zeros(Xb.shape, dtype=np.float32)
for i in xrange(Xb.shape[0]):
Xbb[i] = augment_partial(Xb[i])
return Xbb
# Augments a single image, singled out for easier profiling
评论列表
文章目录