nv-tlabs / GSCNN

Gated-Shape CNN for Semantic Segmentation (ICCV 2019)
https://nv-tlabs.github.io/GSCNN/
Other
916 stars 200 forks source link

Is Canny indeed applied? #22

Open VladVin opened 5 years ago

VladVin commented 5 years ago

In the model's forward code there is a cv2.Canny function call: https://github.com/nv-tlabs/GSCNN/blob/64f84878c6d4aabbf74d7e74fe27f38aa408c7ec/network/gscnn.py#L287-L288 It works for images of np.uint8 type. But the image was preprocessed in the dataset using torchvision transforms which converts image to range [0.0, 1.0]. Converting the image back to np.uint8 from the range [0.0, 1.0] leaves 0 and 1 values only which are lower than the lowest threshold in the Canny call - Canny will not find any edges on such an image.

So, I'm wondering whether this operation has an effect, or have I lost some conversion operation?

John1231983 commented 4 years ago

Same question @tovacinni.

@VladVin have you figure out the solution and reason? I think we should multiply im_arr with 255 before feeding to canny edge

kampelmuehler commented 4 years ago

@VladVin interestingly it works fine as is. I've tried an example and the input is in range [-2.1, 2.6] and is then upscaled by the astype call to [0, 255]. It doesn't feel very comfortable, but the edge map output looks legit.

niecongchong commented 4 years ago

@kampelmuehler I perform normalization ((img-mean)/std) to a image, and img.astype(np.uint8) will add 256 to the negative number. Then I try cv2.Canny, the result is greatly different with the canny result on original image.