def apply_relighting_tensor(tensor, alpha, beta):
tensor = tensor * 255.0
new_tensor = tensor.to(torch.uint8)
new_tensor = new_tensor * alpha + beta / 255.0
new_tensor = torch.abs(new_tensor)
new_tensor = new_tensor.to(torch.float32)
new_tensor = new_tensor / 255.0
return new_tensor
I know that this value is normal, but it has no gradient
But when I use floating point numbers, the effect of the generated image is not what I want at all. I don’t know what to do.
def apply_relighting_tensor(tensor, alpha, beta):
tensor_float = tensor * 255.0
new_tensor = tensor_float * alpha + beta
new_tensor = torch.clamp(new_tensor, 0, 255)
new_tensor = new_tensor / 255.0