I have an image tensor size of BxCxHxW (i.e 2x3x256x256), and a ground-truth label size of Bx1xHxW (i.e. 2x1x256x256). In the label, I have a circle region that can find by
circle = gt > 0

I want to keep image intensity(in the image tensor) no changing if they are in the circle region. And change intensity to -255 if outside the circle. This is my code
in_circle=(gt>0).float
out_circle = 1- circle
in_circle=in_circle.cuda()
out_circle = out_circle .cuda()
image_new = image*in_circle -  out_circle*255               

The above script works but it has a problem that I need to convert to float and cuda although the gt are already float and cuda. Do we have better way to do it?