| 117 | |
| 118 | |
| 119 | def augmentation_seg(img, seg_img, bbox, data_split): |
| 120 | if getattr(cfg, 'no_aug', False): |
| 121 | scale, rot, color_scale, do_flip = 1.0, 0.0, np.array([1, 1, 1]), False |
| 122 | elif data_split == 'train': |
| 123 | scale, rot, color_scale, do_flip = get_aug_config() |
| 124 | else: |
| 125 | scale, rot, color_scale, do_flip = 1.0, 0.0, np.array([1, 1, 1]), False |
| 126 | |
| 127 | img, trans, inv_trans = generate_patch_image(img, bbox, scale, rot, do_flip, cfg.input_img_shape) |
| 128 | seg_img, _, _ = generate_patch_image(seg_img, bbox, scale, rot, do_flip, cfg.input_img_shape) |
| 129 | focal_scale = cfg.input_img_shape[1] / (bbox[2] * scale) |
| 130 | img = np.clip(img * color_scale[None, None, :], 0, 255) |
| 131 | return img, seg_img, trans, inv_trans, rot, do_flip, focal_scale |
| 132 | |
| 133 | |
| 134 | def generate_patch_image(cvimg, bbox, scale, rot, do_flip, out_shape): |