rodrigo2019/keras_yolo2

BGR or RGB in train vs predict

Closed this issue · 2 comments

It seems to me that in training we have:

elif self._config['IMAGE_C'] == 3:
    image = cv2.imread(image_name)
...
image = cv2.resize(image, (self._config['IMAGE_W'], self._config['IMAGE_H']))
image = image[..., ::-1]
... and later in getitem ...
if self._norm is not None:
    x_batch[instance_count] = self._norm(img) (which is also done on predict)

So that we invert colour to have RGB.

But in prediction:

image = cv2.imread(image_path)
boxes = yolo.predict(image)
... and in frontend ...
image = cv2.resize(image, (self._input_size[1], self._input_size[0]))
image = self._feature_extractor.normalize(image)

So we never change its channels so it is BGR.

Am I missing something or is it actually a bug?

Best regards
Filip Mróz

Hmm it is in some of the feature_extractor.normalize.
But it is also used in training.

@Fafa87 it's a bug, could you open a PR to fix it?