In Kornia, using RandomHorizontalFlip(p=0.5)
, you can determine whether the flip was actually applied by inspecting the internal parameters stored in the AugmentationSequential
pipeline after the forward pass. Specifically, Kornia tracks the applied parameters for each transform in the _params
attribute. After passing your image and keypoints through the pipeline, you can access self.train_augments._params["RandomHorizontalFlip"]["batch_prob"]
to get a boolean tensor indicating whether the flip was applied to each item in the batch. This is especially important when working with keypoints, as you’ll need to conditionally update them using your flip index mapping only if the flip was applied. If you're using same_on_batch=True
, then all items in the batch are either flipped or not, so you can check just the first value. This approach allows you to maintain alignment between augmented images and their corresponding keypoints accurately.