PyTorch for Object detection - Image augmentation
I am using PyTorch for object detection and refining an existing model (transfer learning) as described in the following link -
https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html
While different transformations are used for image augmentation (horizontal flip in this tutorial), the tutorial doesnt mention anything on transforming the bounding box/annotation to ensure they are in line with the transformed image. Am I missing something basic here?

In the training phase, the transforms are indeed applied on both images and targets, while loading the data. In the PennFudanDataset class, we have these two lines:
if self.transforms is not None:  
    img, target = self.transforms(img, target)

where target is a dictionary containing:
target = {}
target[&quot;boxes&quot;] = boxes
target[&quot;labels&quot;] = labels
target[&quot;masks&quot;] = masks
target[&quot;image_id&quot;] = image_id
target[&quot;area&quot;] = area
target[&quot;iscrowd&quot;] = iscrowd

self.transforms() in PennFudanDataset class is set to a list of transforms comprising [transforms.ToTensor(), transforms.Compose()], the return value from get_transform() while instantiating the dataset with:
dataset = PennFudanDataset('PennFudanPed', get_transform(train=True))

The transforms transforms.Compose() comes from T, a custom transform written for object detection task. Specifically, in the __call__ of RandomHorizontalFlip(), we process both the image and target (e.g., mask, keypoints):
For the sake of completeness, I borrow the code from the github repo:
def __call__(self, image, target):
        if random.random() &lt; self.prob:
            height, width = image.shape[-2:]
            image = image.flip(-1)
            bbox = target[&quot;boxes&quot;]
            bbox[:, [0, 2]] = width - bbox[:, [2, 0]]
            target[&quot;boxes&quot;] = bbox
            if &quot;masks&quot; in target:
                target[&quot;masks&quot;] = target[&quot;masks&quot;].flip(-1)
            if &quot;keypoints&quot; in target:
                keypoints = target[&quot;keypoints&quot;]
                keypoints = _flip_coco_person_keypoints(keypoints, width)
                target[&quot;keypoints&quot;] = keypoints
        return image, target

Here, we can understand how they perform the flipping on the masks and keypoints in accordance with the image.
