DB
DB copied to clipboard
Question about color channel: RGB or BGR?
@MhLiao, thank you for sharing this great work. I have a question about the color channel order of your code. In demo.py, you seem to use RGB mean of ImageNet. https://github.com/MhLiao/DB/blob/f08c44faa1b4790039381203a8079d73a77494b4/demo.py#L48
But, as far as I know, opencv uses BGR format. https://github.com/MhLiao/DB/blob/f08c44faa1b4790039381203a8079d73a77494b4/demo.py#L91 Is this correct? Am I missing something?
@MhLiao, thank you for sharing this great work. I have a question about the color channel order of your code. In demo.py, you seem to use RGB mean of ImageNet. https://github.com/MhLiao/DB/blob/f08c44faa1b4790039381203a8079d73a77494b4/demo.py#L48
But, as far as I know, opencv uses BGR format. https://github.com/MhLiao/DB/blob/f08c44faa1b4790039381203a8079d73a77494b4/demo.py#L91
Is this correct? Am I missing something?
I have the same question? do you have sloved it now?
@MhLiao, @qutrino, and @lifei1229, the color order for opencv is definitely BGR, but it's not clear if switching them back is the proper thing to as it depends on whether or not the text detection portions of the model were trained on output from backbones with colors reversed. @MhLiao seems to placed his attentions away from this project, unfortunately, so digging into the training code may be the only route to determining the answer.
@MhLiao, @qutrino, and @lifei1229, during training the images are loaded with a torch DataLoader, which uses RGB order. So it would appear that reversing the channel ordering immediately after loading with opencv is the correct thing to do. E.g.,
img = cv2.imread(image_path, cv2.IMREAD_COLOR).astype('float32')
img = img[:, :, ::-1]