my code snippet is below
Now ,the img ,gt do different RandomResizedCrop. But I want they do the same, because the img and gt must be correspond.
How should I modify the code?
my code snippet is below
This thread might be relevant
Read the topic above, and then read some Github issues. Now, I think the best solution is to write own transform(take both image and target as arguments).
For example, my initial question can be solved as below.
Now, the transform result of image and target are same. Here, mainly use torchvision.Transform.get_params()
and torchvision.transforms.functional.xxx
.
The Github Issue link mentioned above: https://github.com/pytorch/vision/issues/230.
If you want convenience, you can git clone
https://github.com/pytorch/vision/blob/main/references/segmentation/transforms.py to your workspace.(My solution is also mimic him)