def __init__(self, anchors, shape, sigma=0.5, randrange=None):
        """
        Args:
            anchors (list): list of center coordinates in range [0,1].
            shape(list or tuple): image shape in [h, w].
            sigma (float): sigma for Gaussian weight
            randrange (int): offset range. Defaults to shape[0] / 8
        """
        logger.warn("GaussianDeform is slow. Consider using it with 4 or more prefetching processes.")
        super(GaussianDeform, self).__init__()
        self.anchors = anchors
        self.K = len(self.anchors)
        self.shape = shape
        self.grid = np.mgrid[0:self.shape[0], 0:self.shape[1]].transpose(1, 2, 0)
        self.grid = self.grid.astype('float32')  # HxWx2

        gm = GaussianMap(self.shape, sigma=sigma)
        self.gws = np.array([gm.get_gaussian_weight(ank)
                             for ank in self.anchors], dtype='float32')  # KxHxW
        self.gws = self.gws.transpose(1, 2, 0)  # HxWxK
        if randrange is None:
            self.randrange = self.shape[0] / 8
        else:
            self.randrange = randrange
        self.sigma = sigma
def __init__ ( self , anchors , shape , sigma = 0.5 , randrange = None ) : logger . warn ( "GaussianDeform is slow. Consider using it with 4 or more prefetching processes." ) super ( GaussianDeform , self ) . __init__ ( ) self . anchors = anchors self . K = len ( self . anchors ) self . shape = shape self . grid = np . mgrid [ 0 : self . shape [ 0 ] , 0 : self . shape [ 1 ] ] . transpose ( 1 , 2 , 0 ) self . grid = self . grid . astype ( 'float32' ) gm = GaussianMap ( self . shape , sigma = sigma ) self . gws = np . array ( [ gm . get_gaussian_weight ( ank ) for ank in self . anchors ] , dtype = 'float32' ) self . gws = self . gws . transpose ( 1 , 2 , 0 ) if randrange is None : self . randrange = self . shape [ 0 ] / 8 else : self . randrange = randrange self . sigma = sigma
Args:
            anchors (list): list of center coordinates in range [0,1].
            shape(list or tuple): image shape in [h, w].
            sigma (float): sigma for Gaussian weight
            randrange (int): offset range. Defaults to shape[0] / 8