haofeixu / aanet

[CVPR'20] AANet: Adaptive Aggregation Network for Efficient Stereo Matching
Apache License 2.0
521 stars 100 forks source link

Data PreProcess with np.float32 to transforms.ToTensor() #62

Closed oliverxudd closed 3 years ago

oliverxudd commented 3 years ago

Hi, haofeixu, I have a simple question about data preprocessing.

In my understanding, the data preprocess from 1) inference.py 2) dataloader.dataloader.py 3) utils.file_io.py is:

step1, read_img() from file_io.py, read image as np.float32, ranging from 0 to 255.0 step2, transform as in

test_transform = transforms.Compose([
    transforms.ToTensor(),
    transforms.Normalize(mean=IMAGENET_MEAN, std=IMAGENET_STD)])
IMAGENET_MEAN = [0.485, 0.456, 0.406]
IMAGENET_STD = [0.229, 0.224, 0.225]

The problem is transform.ToTensor() will not normalize image to [0,1] if np.dtype is not np.uint8 doc.

I don't know if this will be a problem. I hope not.

haofeixu commented 3 years ago

Hi @oliverxudd , please note that the transforms used in this repo is not pytorch's transforms, it is defined here: https://github.com/haofeixu/aanet/blob/master/dataloader/transforms.py.

We have normalized the images to [0, 1] in ToTensor(): https://github.com/haofeixu/aanet/blob/f689abf81ef072b4e50eb480d3a73db66eebda44/dataloader/transforms.py#L23-L26

oliverxudd commented 3 years ago

This clear things up. Thx!