import torch
import pystiche_papers.sanakoyeu_et_al_2018 as paper
crop_width = 100
crop_height = 1
torch.manual_seed(0)
image_width = crop_width * 2
image_height = crop_height * 2
anchors = paper.RandomCrop.generate_anchors(
batch_size=1,
image_size=(image_height, image_width),
crop_size=(crop_height, crop_width),
same_on_batch=True,
)
anchor = anchors[0, 0, :]
print(anchor)
x, y = anchor.tolist()
assert x < image_width, f"{x} >= {image_width}"
assert y < image_height, f"{y} >= {image_height}"
tensor([ 0, 77], dtype=torch.int32)
AssertionError: 77 >= 2
This happens because the image and crop size place the height before the width (as is the default in PyTorch)
https://github.com/pmeier/pystiche_papers/blob/f47871f9334d21adc27de979c2480274bb73170e/pystiche_papers/sanakoyeu_et_al_2018/_data.py#L194-L200
whereas kornia.augmentation.functional.apply_crop expects the horizontal coordinate before the vertical.
Cc @jbueltemeier