Replies: 1 comment
-
A workaround is to introduce an object_id field as additional data. import skimage as ski
img = ski.transform.resize(ski.data.cat(), (1000, 1000))
transforms = A.Compose(
[
A.HorizontalFlip(p=1.0),
A.VerticalFlip(p=1.0)
],
keypoint_params=A.KeypointParams(format="xy", label_fields=["object_ids"])
)
keypoints = [(502, 452), (554, 426), (670, 186), (673, 180)]
object_ids = [0, 0, 1, 1]
transformed = transforms(
image=img,
keypoints=keypoints,
object_ids=object_ids
)
kps = {}
for kp, obj in zip(transformed["keypoints"], transformed["object_ids"]):
kps.setdefault(obj, []).append(kp)
print(kps)
# {0: [(497, 547), (445, 573)], 1: [(329, 813), (326, 819)]} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm working with torchvision's Keypoint-RCNN and I'm trying to migrate the augmentations to Albumentations. However, I'm having some trouble.
How can I do augmentation for keypoints of multiple objects? Let's say I'm trying to do a flip on an image with various people, for which I have labelled the eyes of each of them. That is, each person has as keypoints the left and the right eyes.
This throws me an error. However, it works fine if I do:
keypoints = [(502, 452), (554, 426), (670, 186), (673, 180)]
Notice the difference: in the first case I have a list of lists. I have two objects, each with 2 keypoints. In the second case I have a list of keypoints. It's a single object with 4 keypoints. It doesn't take into account at all to whom the keypoints belong.
The second way throws me an error in torchvision: "keypoints must be of shape (num_instances, K, 2)"
How can I work around this?
Beta Was this translation helpful? Give feedback.
All reactions