(img: Tensor, scale: List[float],
                   ratio: List[float])
return i, j, h, w
Get parameters for ``crop`` for a random sized crop.

        Args:
            img (PIL Image or Tensor): Input image.
            scale (list): range of scale of the origin size cropped
            ratio (list): range of aspect ratio of the origin aspect ratio cropped

        Returns:
            tuple: params (i, j, h, w) to be passed to ``crop`` for a random
            sized crop.
Get parameters for ``crop`` for a random sized crop.
Get parameters for crop for a random sized crop .
def get_params(img: Tensor, scale: List[float],
                   ratio: List[float]) -> Tuple[int, int, int, int]:
        """Get parameters for ``crop`` for a random sized crop.

        Args:
            img (PIL Image or Tensor): Input image.
            scale (list): range of scale of the origin size cropped
            ratio (list): range of aspect ratio of the origin aspect ratio cropped

        Returns:
            tuple: params (i, j, h, w) to be passed to ``crop`` for a random
            sized crop.
        """
        width, height = F._get_image_size(img)
        area = height * width

        log_ratio = paddle.log(paddle.to_tensor(ratio))
        for _ in range(10):
            target_area = area * paddle.uniform(
                shape=[1], min=scale[0], max=scale[1]).numpy().item()
            aspect_ratio = paddle.exp(
                paddle.uniform(
                    shape=[1], min=log_ratio[0], max=log_ratio[1])).numpy(
                    ).item()

            w = int(round(math.sqrt(target_area * aspect_ratio)))
            h = int(round(math.sqrt(target_area / aspect_ratio)))

            if 0 < w <= width and 0 < h <= height:
                i = paddle.randint(
                    0, height - h + 1, shape=(1, )).numpy().item()
                j = paddle.randint(
                    0, width - w + 1, shape=(1, )).numpy().item()
                return i, j, h, w

        # Fallback to central crop
        in_ratio = float(width) / float(height)
        if in_ratio < min(ratio):
            w = width
            h = int(round(w / min(ratio)))
        elif in_ratio > max(ratio):
            h = height
            w = int(round(h * max(ratio)))
        else:  # whole image
            w = width
            h = height
        i = (height - h) // 2
        j = (width - w) // 2
        return i, j, h, w
def get_params ( img : Tensor , scale : List [ float ] , ratio : List [ float ] ) -> Tuple [ int , int , int , int ] : width , height = F . _get_image_size ( img ) area = height * width log_ratio = paddle . log ( paddle . to_tensor ( ratio ) ) for _ in range ( 10 ) : target_area = area * paddle . uniform ( shape = [ 1 ] , min = scale [ 0 ] , max = scale [ 1 ] ) . numpy ( ) . item ( ) aspect_ratio = paddle . exp ( paddle . uniform ( shape = [ 1 ] , min = log_ratio [ 0 ] , max = log_ratio [ 1 ] ) ) . numpy ( ) . item ( ) w = int ( round ( math . sqrt ( target_area * aspect_ratio ) ) ) h = int ( round ( math . sqrt ( target_area / aspect_ratio ) ) ) if 0 < w <= width and 0 < h <= height : i = paddle . randint ( 0 , height - h + 1 , shape = ( 1 , ) ) . numpy ( ) . item ( ) j = paddle . randint ( 0 , width - w + 1 , shape = ( 1 , ) ) . numpy ( ) . item ( ) return i , j , h , w # Fallback to central crop in_ratio = float ( width ) / float ( height ) if in_ratio < min ( ratio ) : w = width h = int ( round ( w / min ( ratio ) ) ) elif in_ratio > max ( ratio ) : h = height w = int ( round ( h * max ( ratio ) ) ) else : # whole image w = width h = height i = ( height - h ) // 2 j = ( width - w ) // 2 return i , j , h , w