sacmehta / ESPNet

ESPNet: Efficient Spatial Pyramid of Dilated Convolutions for Semantic Segmentation
https://sacmehta.github.io/ESPNet/
MIT License
538 stars 111 forks source link

double scale in test code #72

Closed cheninnovasea closed 4 years ago

cheninnovasea commented 4 years ago

https://github.com/sacmehta/ESPNet/blob/afe71c38edaee3514ca44e0adcafdf36109bf437/test/VisualizeResults.py#L75-L85

Hi Author,

It seems the image is double scaled in the test code, however, in the training code data transform, only one normalization applied. Why do we use double scale in test? I tried the code, it seems we need to keep double scale in test code, otherwise it doesn't produce right result, just wondering how do this works?

Thanks, Chen

sacmehta commented 4 years ago

What do you mean by double scaled? If you are referring to Line 80 and 81, then Line 81 code is merely a copy of Line 80 and the image created at Line 81 is only used for overlay and is not fed to the network.

sacmehta commented 4 years ago

And if you are referring to normalization, then first mean is subtracted and then resultant output is divided by standard deviation. These operations are per channel and are equivalent to Normalize function in PyTorch.

cheninnovasea commented 4 years ago

I mean in line 75-78, it did the normalization, however at line 85, img /= 255, it scaled the pixel value one more time. However, the training code just did the line 75-78, so the preparation of data seems not match. Or did I missed some step there?

sacmehta commented 4 years ago

We also do it during training:

https://github.com/sacmehta/ESPNet/blob/afe71c38edaee3514ca44e0adcafdf36109bf437/train/Transforms.py#L143

This is done to restrict the values between 0 and 1 or (-1 and 1).