forked from TensorLayer/tensorlayer3
19 lines
334 B
Python
19 lines
334 B
Python
import numpy as np
|
|
|
|
def _preprocess_numpy_input(x):
|
|
|
|
|
|
# 'RGB'->'BGR'
|
|
x = x[..., ::-1]
|
|
mean = [103.939, 116.779, 123.68]
|
|
std = None
|
|
x[..., 0] -= mean[0]
|
|
x[..., 1] -= mean[1]
|
|
x[..., 2] -= mean[2]
|
|
if std is not None:
|
|
x[..., 0] /= std[0]
|
|
x[..., 1] /= std[1]
|
|
x[..., 2] /= std[2]
|
|
return x
|
|
|