Pytorch_Retinaface icon indicating copy to clipboard operation
Pytorch_Retinaface copied to clipboard

Input is not normalized to [-1, 1]

Open eeewhe opened this issue 5 years ago • 8 comments
trafficstars

Hi, Why the input is not normalized to -1.~1. ?

img -= (104, 117, 123)

eeewhe avatar Dec 13 '19 10:12 eeewhe

When I add the following code, and train & validate

img[0, :, :] = img[0, :, :] / 57. #b
img[1, :, :] = img[1, :, :] / 57.
img[2, :, :] = img[2, :, :] / 58.

no normalized, long side of image resized to 640. Easy: 0.875 Medium: 0.806 Hard: 0.504

normalized to [-1, 1] Easy: 0.880 Medium: 0.818 Hard: 0.521

eeewhe avatar Dec 25 '19 08:12 eeewhe

When it gets converted to a tensor, the default type is float and the default action in Python will normalise it. However, it won't do this automatically in C++.

So, yes, it is already normalised -1 to 1 on input to the model.

xsacha avatar Dec 25 '19 13:12 xsacha

When it gets converted to a tensor, the default type is float and the default action in Python will normalise it. However, it won't do this automatically in C++.

So, yes, it is already normalised -1 to 1 on input to the model.

do u know why use this code: img -= (104,117,123)?

brealisty avatar Feb 16 '20 16:02 brealisty

That's the mean being subtracted from the image as an unsigned char array, prior to normalisation. That BGR value becomes the zero of the normalised values.

I've found the actual mean value of the image appears to work slightly better, especially on highly contrasted images. However, as a constant this value is great.

xsacha avatar Feb 16 '20 21:02 xsacha

That's the mean being subtracted from the image as an unsigned char array, prior to normalisation. That BGR value becomes the zero of the normalised values.

I've found the actual mean value of the image appears to work slightly better, especially on highly contrasted images. However, as a constant this value is great.

yes, before delete this line, always get some wrong box(not face). delet this line will get better performance.

brealisty avatar Feb 17 '20 03:02 brealisty

torch.from_numpy()? This line wouldn't convert to -1-1 or 0-1.

eeewhe avatar May 20 '20 09:05 eeewhe

image It is not normalized.

gengyanlei avatar Sep 14 '20 01:09 gengyanlei

The inputs are the range of [-104:151, -117:138, -123:132]. They aren't normalised to 1.

xsacha avatar Sep 14 '20 01:09 xsacha