does is affect NN training accuracy if the color format of images is BGR not RGB?

Issue

I’m training Neural Network with ImageNet dataset and I noticed that images are in BGR color format when I read them using OpenCV function cv2.imread(), so does is affect training accuracy?, if yes then how can I change it to RGB in pytorch?

Solution

It will not affect your NN’s accuracy, in general. However, if you are using a pre-trained CNN, then it likely expects RGB images as input, and will not do as well on BGR images initially and will have to re-learn its weights for BGR.

You can convert BGR to RGB using cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB).

You can also consider the following alternatives for reading images:

Answered By – adeelh

Answer Checked By – Jay B. (AngularFixing Admin)

Leave a Reply

Your email address will not be published.