You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

paddle_image.py 461 B

4 years ago
12345678910111213141516171819
  1. import paddle
  2. import numpy as np
  3. from PIL import Image
  4. from paddle.vision.transforms import functional as F
  5. __all_ = [
  6. 'Standardization',
  7. ]
  8. def Standardization(img, mean, std, data_format='HWC'):
  9. if data_format == 'CHW':
  10. mean = paddle.to_tensor(mean).reshape([-1, 1, 1])
  11. std = paddle.to_tensor(std).reshape([-1, 1, 1])
  12. else:
  13. mean = paddle.to_tensor(mean)
  14. std = paddle.to_tensor(std)
  15. return (img - mean) / std

TensorLayer3.0 是一款兼容多种深度学习框架为计算后端的深度学习库。计划兼容TensorFlow, Pytorch, MindSpore, Paddle.