Args: image: pytorch Image tensor from PIL (range 0~1), bgr format mean : norm mean std : norm val Returns: A image norm in 0~255, rgb format
(image, mean=[104, 117, 128], std=[1, 1, 1])
| 9 | |
| 10 | |
| 11 | def bninceptionPre(image, mean=[104, 117, 128], std=[1, 1, 1]): |
| 12 | """ |
| 13 | Args: |
| 14 | image: pytorch Image tensor from PIL (range 0~1), bgr format |
| 15 | mean : norm mean |
| 16 | std : norm val |
| 17 | Returns: |
| 18 | A image norm in 0~255, rgb format |
| 19 | """ |
| 20 | expand_batch_dim = len(image.size()) == 3 |
| 21 | if expand_batch_dim: |
| 22 | image = image.unsqueeze(0) |
| 23 | image = image * 255 |
| 24 | image = image[:, [2, 1, 0]] |
| 25 | for i in range(2): |
| 26 | image[:, i, ...] -= mean[i] |
| 27 | image[:, i, ...] /= std[i] |
| 28 | return image |
| 29 | |
| 30 | |
| 31 | def randomErasing(image, |