Keras loading images in incorrect format So I was working with the the vgg16 model for dogs vs cats classification and I noticed that keras is not loading images in correct color format.
The code is as follows:

import cv2
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
from keras.preprocessing import image

path='data/dogscats/sample/train/dogs/dog.1402.jpg'

imgkeras=image.load_img(path)
imgkeras=image.img_to_array(imgkeras)

plt.imshow(imgkeras)
plt.show()


The output of the following code is


Where as the original image is 



Can someone explain why is this happening? , also when the image is loaded through opencv and fed into vgg16 the predicted label is more accurate for this particular image than when it is loaded through keras as above,is the improper color format affecting that?
This is caused due to the img_to_array method which converts the image to a float32 array.

x = np.asarray(img, dtype=K.floatx())


Matplotlib interprets NxMx3 uint8 array as a standard image (0..255 components) in which case there is no preprocessing. Otherwise the pixels are multiplied by 255(without checking the range) and then cast into uint8, which I guess leads to this behaviour.

Check this:https://stackoverflow.com/questions/39925420/bizzare-matplotlib-behaviour-in-displaying-images-cast-as-floats

To answer the second part of your question, I guess the imagenet competitors used OpenCV to load images in BGR format to train vgg16 and hence the pretrained weights work well with images opened in BGR format.