augment.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:luna16 作者: gzuidhof 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号