(ori_size, crop_size)
| 42 | |
| 43 | |
| 44 | def generate_random_crop_pos(ori_size, crop_size): |
| 45 | ori_size = get_2dshape(ori_size) |
| 46 | h, w = ori_size |
| 47 | |
| 48 | crop_size = get_2dshape(crop_size) |
| 49 | crop_h, crop_w = crop_size |
| 50 | |
| 51 | pos_h, pos_w = 0, 0 |
| 52 | |
| 53 | if h > crop_h: |
| 54 | pos_h = random.randint(0, h - crop_h + 1) |
| 55 | |
| 56 | if w > crop_w: |
| 57 | pos_w = random.randint(0, w - crop_w + 1) |
| 58 | |
| 59 | return pos_h, pos_w |
| 60 | |
| 61 | |
| 62 | def pad_image_to_shape(img, shape, border_mode, value): |