|
3 | 3 | Transforms on KeyPoints |
4 | 4 | =============================================================== |
5 | 5 |
|
6 | | -This example illustrates how to define and use rotated bounding boxes. |
| 6 | +This example illustrates how to define and use keypoints. |
7 | 7 |
|
8 | 8 | .. note:: |
9 | 9 | Support for keypoints was released in TorchVision 0.23 and is |
|
75 | 75 | # Using :class:`~torchvision.transforms.RandomRotation`: |
76 | 76 | rotater = v2.RandomRotation(degrees=(0, 180), expand=True) |
77 | 77 | rotated_imgs = [rotater((orig_img, orig_pts)) for _ in range(4)] |
78 | | -plot([(orig_img, orig_pts)] + rotated_imgs, bbox_width=10) |
| 78 | +plot([(orig_img, orig_pts)] + rotated_imgs) |
79 | 79 |
|
80 | 80 | # %% |
81 | 81 | # Using :class:`~torchvision.transforms.Pad`: |
82 | 82 | padded_imgs_and_points = [ |
83 | 83 | v2.Pad(padding=padding)(orig_img, orig_pts) |
84 | 84 | for padding in (30, 50, 100, 200) |
85 | 85 | ] |
86 | | -plot([(orig_img, orig_pts)] + padded_imgs_and_points, bbox_width=10) |
| 86 | +plot([(orig_img, orig_pts)] + padded_imgs_and_points) |
87 | 87 |
|
88 | 88 | # %% |
89 | 89 | # Using :class:`~torchvision.transforms.Resize`: |
90 | 90 | resized_imgs = [ |
91 | 91 | v2.Resize(size=size)(orig_img, orig_pts) |
92 | 92 | for size in (300, 500, 1000, orig_img.size) |
93 | 93 | ] |
94 | | -plot([(orig_img, orig_pts)] + resized_imgs, bbox_width=5) |
| 94 | +plot([(orig_img, orig_pts)] + resized_imgs) |
95 | 95 |
|
96 | 96 | # %% |
97 | 97 | # Using :class:`~torchvision.transforms.RandomPerspective`: |
98 | 98 | perspective_transformer = v2.RandomPerspective(distortion_scale=0.6, p=1.0) |
99 | 99 | perspective_imgs = [perspective_transformer(orig_img, orig_pts) for _ in range(4)] |
100 | | -plot([(orig_img, orig_pts)] + perspective_imgs, bbox_width=10) |
| 100 | +plot([(orig_img, orig_pts)] + perspective_imgs) |
101 | 101 |
|
102 | 102 | # %% |
103 | 103 | # Using :class:`~torchvision.transforms.CenterCrop`: |
|
0 commit comments