forked from aleju/imgaug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_rot90.py
58 lines (51 loc) · 2.58 KB
/
check_rot90.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from __future__ import print_function, division
import imgaug as ia
from imgaug import augmenters as iaa
def main():
augs = [
("iaa.Rot90(-1, keep_size=False)", iaa.Rot90(-1, keep_size=False)),
("iaa.Rot90(0, keep_size=False)", iaa.Rot90(0, keep_size=False)),
("iaa.Rot90(1, keep_size=False)", iaa.Rot90(1, keep_size=False)),
("iaa.Rot90(2, keep_size=False)", iaa.Rot90(2, keep_size=False)),
("iaa.Rot90(3, keep_size=False)", iaa.Rot90(3, keep_size=False)),
("iaa.Rot90(4, keep_size=False)", iaa.Rot90(4, keep_size=False)),
("iaa.Rot90(-1, keep_size=True)", iaa.Rot90(-1, keep_size=True)),
("iaa.Rot90(0, keep_size=True)", iaa.Rot90(0, keep_size=True)),
("iaa.Rot90(1, keep_size=True)", iaa.Rot90(1, keep_size=True)),
("iaa.Rot90(2, keep_size=True)", iaa.Rot90(2, keep_size=True)),
("iaa.Rot90(3, keep_size=True)", iaa.Rot90(3, keep_size=True)),
("iaa.Rot90(4, keep_size=True)", iaa.Rot90(4, keep_size=True)),
("iaa.Rot90([0, 1, 2, 3, 4], keep_size=False)", iaa.Rot90([0, 1, 2, 3, 4], keep_size=False)),
("iaa.Rot90([0, 1, 2, 3, 4], keep_size=True)", iaa.Rot90([0, 1, 2, 3, 4], keep_size=True)),
("iaa.Rot90((0, 4), keep_size=False)", iaa.Rot90((0, 4), keep_size=False)),
("iaa.Rot90((0, 4), keep_size=True)", iaa.Rot90((0, 4), keep_size=True)),
("iaa.Rot90((1, 3), keep_size=False)", iaa.Rot90((1, 3), keep_size=False)),
("iaa.Rot90((1, 3), keep_size=True)", iaa.Rot90((1, 3), keep_size=True))
]
image = ia.data.quokka(0.25)
print("--------")
print("Image + Keypoints")
print("--------")
kps = ia.quokka_keypoints(0.25)
for name, aug in augs:
print(name, "...")
aug_det = aug.to_deterministic()
images_aug = aug_det.augment_images([image] * 16)
kps_aug = aug_det.augment_keypoints([kps] * 16)
images_aug = [kps_aug_i.draw_on_image(image_aug_i, size=5)
for image_aug_i, kps_aug_i in zip(images_aug, kps_aug)]
ia.imshow(ia.draw_grid(images_aug))
print("--------")
print("Image + Heatmaps (low res)")
print("--------")
hms = ia.quokka_heatmap(0.10)
for name, aug in augs:
print(name, "...")
aug_det = aug.to_deterministic()
images_aug = aug_det.augment_images([image] * 16)
hms_aug = aug_det.augment_heatmaps([hms] * 16)
images_aug = [hms_aug_i.draw_on_image(image_aug_i)[0]
for image_aug_i, hms_aug_i in zip(images_aug, hms_aug)]
ia.imshow(ia.draw_grid(images_aug))
if __name__ == "__main__":
main()