TreB1eN / InsightFace_Pytorch

Pytorch0.4.1 codes for InsightFace
MIT License
1.73k stars 423 forks source link

Some errors about image color #13

Closed lvvvmd closed 5 years ago

lvvvmd commented 5 years ago

Hi, Thanks for your great contribute on this open source work! But I have a few questions! Firstly, I downloaded the faces_webface_112x112.zip from InsightFace Dataset zoo. Then I unzipped the data and followed your instruction to generate training imgs but I got such images! image image It looks like an issue about RGB channel and BGR channel. So i wonder whether its color is correct. Thank you!

TreB1eN commented 5 years ago

I'm not sure, I didn't use this dataset, but I think if bgr or rgb channels are mistaken, the image would look much weirder ... You can try to manipulate the channels to have a look.

cvtower commented 5 years ago

Hi all,

This is BGR format image, which is easy to verify. All images under folder /faces_emore/imgs are BGR images too.

JingyuanHu commented 5 years ago

I'm confused too. All images under folder /faces_emore/imgs are BGR format and I dont find the RGB transpose in this training code. However, I found these code in face_verify.py: image = Image.fromarray(frame[...,::-1]) #bgr to rgb

cvtower commented 5 years ago

data_pipe.py +line 59 img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR).

JingyuanHu commented 5 years ago

Yeah, that's true. But it is different, right?

  1. Line59 in data_pipe.py is used for preprocessing data which is validation data such as lfw, cfp_fp. This operation can transform these data from rgb to bgr. So, that means the data used for networks is in BGR format.
  2. However, in face_verify.py, RGB data is used. It's strange, right? It must be a transform in some place, but I dont find where it is.

That's why I'm confused.

TreB1eN commented 5 years ago

Hi, guys, after check on the codes, the conclusion is all the traning and evaluation image are all in bgr format, so the main codes are ok. The problem is I shouldn't change the format during inference, so I have updated the following codes image = Image.fromarray(frame[...,::-1]) #bgr to rgb to: image = Image.fromarray(frame) #bgr input format in face_verify.py and infer_on_video.py

JingyuanHu commented 5 years ago

Got it, thank you @TreB1eN

wanjinchang commented 4 years ago

Yeah, that's true. But it is different, right?

  1. Line59 in data_pipe.py is used for preprocessing data which is validation data such as lfw, cfp_fp. This operation can transform these data from rgb to bgr. So, that means the data used for networks is in BGR format.
  2. However, in face_verify.py, RGB data is used. It's strange, right? It must be a transform in some place, but I dont find where it is.

That's why I'm confused.

Line92 in data_pipe.py is used for saving face images which used for training in RGB format. So, that means the data used for training is in RGB format???!!!