Hi,



 xyry:

data,rect=tfs.RandomCrop((h,w))(data)


RandomCrop does not return a tuple. It only crops the image and returns a Image object containing the cropped image. If you want the exact crop indices, you need to first create a RandomCrop object, then use its static method .get_params(image, output_size) which returns starting indices i and j and and the length of height and width th and tw respectively.  After this, you can call torch.nn.functional.crop(img, i, j, th, tw) to get cropped image.
I think my explanation was a little bit complex, in this case you can read the source of RandomCrop, but I have just added the main methods here:
    def get_params(img, output_size):
        """Get parameters for ``crop`` for a random crop.

        Args:
            img (PIL Image): Image to be cropped.
            output_size (tuple): Expected output size of the crop.

        Returns:
            tuple: params (i, j, h, w) to be passed to ``crop`` for random crop.
        """
        w, h = _get_image_size(img)
        th, tw = output_size
        if w == tw and h == th:
            return 0, 0, h, w

        i = random.randint(0, h - th)
        j = random.randint(0, w - tw)
        return i, j, th, tw

    def __call__(self, img):
        """
        Args:
            img (PIL Image): Image to be cropped.

        Returns:
            PIL Image: Cropped image.
        """
        if self.padding is not None:
            img = F.pad(img, self.padding, self.fill, self.padding_mode)

        # pad the width if needed
        if self.pad_if_needed and img.size[0] < self.size[1]:
            img = F.pad(img, (self.size[1] - img.size[0], 0), self.fill, self.padding_mode)
        # pad the height if needed
        if self.pad_if_needed and img.size[1] < self.size[0]:
            img = F.pad(img, (0, self.size[0] - img.size[1]), self.fill, self.padding_mode)

        i, j, h, w = self.get_params(img, self.size)

        return F.crop(img, i, j, h, w)

Bests