mask = self.affine_transform(mask,affine1);
mask = self.affine_transform(mask, affine_inverse1) # convert truncated pixels to 0
why do you convert warped mask to another mask by "grid sample". Can you use the initial originial mask variable?
At the annotation, you said " convert truncated pixels to 0", but "grid sample" uses bilinear and it can't get binary output.