About torchvision.transforms.functional.adjust_brightness

Hi, when i use torchvision.transforms.functional.adjust_brightness to change the brightness of tensor image, the generated image is not normal, like adding a gray mask on it.
But when i use pil image, the result is right.

import torch
import torch.nn as nn
import torchvision.transforms.functional as F

class Br(nn.Module):
    
    def __init__(self, change):
        super(Br, self).__init__()
        self.change = change
        
    def forward(self, image_and_cover):
        image, cover_image = image_and_cover

        output = F.adjust_brightness(image, self.change)
        return output

The picture below is the result when brightness_factor is setting to 1.0.
epoch-test

I cannot reproduce the issue and get the original image back for PIL.Image and tensor inputs:

pil_image = PIL.Image.open("./tmp03.jpeg")
pil_image

factor = 1.0
output = F.adjust_brightness(pil_image, factor)
output

tensor_image = torch.from_numpy(np.array(pil_image))
tensor_image = tensor_image.permute(2, 0, 1).contiguous()
tensor_output = F.adjust_brightness(tensor_image, factor)

PIL.Image.fromarray(tensor_output.permute(1, 2, 0).contiguous().numpy())

Thank you! I find the reason, when I load the dataset, I performed a normalization operation. So before adjusting the brightness, I should perform the inverse.

image = (image + 1) / 2