Becks Wu
Becks Wu

Reputation: 21

Why Keras preprocess_input() switch RGB to BGR

Documentaion for preprocess_input.

It is mentioned in that

Returns Preprocessed numpy.array or a tf.Tensor with type float32. The images are converted from RGB to BGR, then each color channel is zero-centered with respect to the ImageNet dataset, without scaling.

Why need to convert RGB to BGR? what is the reason behind?

Upvotes: 1

Views: 1028

Answers (1)

yudhiesh
yudhiesh

Reputation: 6799

In the function preprocess_input the default mode used is Caffe which seems to be the only option that you can process images in when using preprocess_input() based on this code.

Caffe uses OpenCV for many image operations, and OpenCV defaults to reading images into BGR.

Upvotes: 1

Related Questions