Open VladVin opened 5 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
@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.
@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.
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 ofnp.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 tonp.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?