lucasjinreal / keras_frcnn

Keras Implementation of faster-rcnn
520 stars 278 forks source link

Issue with BGR an RGB #5

Open pandasMX opened 7 years ago

pandasMX commented 7 years ago

https://github.com/jinfagang/keras_frcnn/blob/8b5d8fa2f1a11b83ebe91ef8486dd2ee5d620ede/keras_frcnn/data_generators.py#L316

From what i understand, to subtract the mean pixel value from ImageNet, this should be correct: `# For Tensorflow

x[:, :, :, (B,G,R)]

Subtract ImageNet mean pixel

x[:, :, :, 0] -= 103.939 #B x[:, :, :, 1] -= 116.779 #G x[:, :, :, 2] -= 123.68 #R`

I noticed you read the image using cv2, the default order for the channel is BGR for cv2. But then you convert it to RGB and subtract the mean pixel value from Imagenet.

What you did is like this: `#x[:, :, :, (R,G,B)]

Subtract ImageNet mean pixel

x[:, :, :, 0] -= 103.939 #R x[:, :, :, 1] -= 116.779 #G x[:, :, :, 2] -= 123.68 #B`

Am i correct? Please check. Thanks

lucasjinreal commented 7 years ago

subtract mean pixel is just minus the certain value in very channel.

AOtrans commented 6 years ago

you are right. it should be BGR

Maswor commented 6 years ago

You are correct, Keras ResNet50 was initially trained with BGR and cv2.imread() read it into BGR by default. Can you make a pull request!