(shape, *, zero=True)
| 10 | |
| 11 | |
| 12 | def get_2dshape(shape, *, zero=True): |
| 13 | if not isinstance(shape, collections.abc.Iterable): |
| 14 | shape = int(shape) |
| 15 | shape = (shape, shape) |
| 16 | else: |
| 17 | h, w = map(int, shape) |
| 18 | shape = (h, w) |
| 19 | if zero: |
| 20 | minv = 0 |
| 21 | else: |
| 22 | minv = 1 |
| 23 | |
| 24 | assert min(shape) >= minv, "invalid shape: {}".format(shape) |
| 25 | return shape |
| 26 | |
| 27 | |
| 28 | def random_crop_pad_to_shape(img, crop_pos, crop_size, pad_label_value): |
no test coverage detected