Open aditya-malte opened 5 years ago
Thanks
while i just used the comment sentence, it can get the right results, and it not divide by 255. why do you think divided by 255 is needed?
Hello, The transform method is defined in the val code as follows:
transform=transforms.Compose([
transforms.ToTensor(),transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225]),
])
The transforms function actually scales the values to [0,1] from [0,255] (range of RGB) before normalization. In order to reduce dependencies(for another project), I had directly performed the operations myself and hence uploaded this code:
im = Image.open(path).convert('RGB')
im = np.array(im)
im = im/255.0
im[:,:,0]=(im[:,:,0]-0.485)/0.229
im[:,:,1]=(im[:,:,1]-0.456)/0.224
im[:,:,2]=(im[:,:,2]-0.406)/0.225
Thank you
Well, I got, tks~
You are welcome :)
@leeyeehoo , Could you commit the updated snippet into repo?
While executing the val code, one gets an unexpected output for crowd count(something random). The probable cause is incorrect normalization values that are substracted. Using the same normalization as while training (using torch transform) seems to solve the problem.
A code akin to this should solve the issue:
Thank you!