You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def_preprocess_symbolic_input(x, data_format, mode):
"""Preprocesses a symbolic image tensor. Arguments: x: symoblic tensor, 3D or 4D. data_format: data format of the image tensor. mode: One of "caffe", "tf". - caffe: will convert the images from RGB to BGR, then will zero-center each color channel with respect to the ImageNet dataset, without scaling. - tf: will scale pixels between -1 and 1, sample-wise. Returns: Preprocessed tensor. """global_IMAGENET_MEANifmode=='tf':
x/=127.5x-=1.returnxifdata_format=='channels_first':
# 'RGB'->'BGR'ifK.ndim(x) ==3:
x=x[::-1, ...]
else:
x=x[:, ::-1, ...]
else:
# 'RGB'->'BGR'x=x[..., ::-1]
if_IMAGENET_MEANisNone:
_IMAGENET_MEAN=K.constant(-np.array([103.939, 116.779, 123.68]))
# Zero-center by mean pixelifK.dtype(x) !=K.dtype(_IMAGENET_MEAN):
x=K.bias_add(x, K.cast(_IMAGENET_MEAN, K.dtype(x)), data_format)
else:
x=K.bias_add(x, _IMAGENET_MEAN, data_format)
returnx
MobileNet preprocess_input is in -1 to 1 range. I use that directly for evaluation purposes.
For the data loaders, the two parse methods that map the file path to an image also have the img - 127.5 / 127.5 line which normalizes to -1 to 1 range.
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/keras/_impl/keras/applications/imagenet_utils.py#L82
https://github.com/titu1994/neural-image-assessment/blob/master/data_loader.py#L59
IMAGENET_MEAN = [103.939, 116.779, 123.68]
or just[127, 127, 127]
?The text was updated successfully, but these errors were encountered: