Skip to content

F.adjust_brightness gives different results for the same np.array and paddle.Tensor inputs when brightness_factor > 1.0 and brightness_factor < 1.0 #56410

Open
@ozogxyz

Description

@ozogxyz

bug描述 Describe the Bug

paddle.vision.transforms.adjust_brightness gives different results for the same np.array and paddle.Tensor inputs.

  • input: [[[1.]]]
  • np.array : returns [[[2.]]]
  • paddle.Tensor returns [[[1.]]]

when brightness_factor > 1.0

To reproduce:

import numpy as np
import paddle

from paddle.vision.transforms import functional as F


img_arr = np.array([[[1.0]]], dtype=np.float32)
tensor_img = paddle.to_tensor(img_arr, dtype="float32")

print(f"np.array input: {img_arr}")
print(f"paddle tensor input: {tensor_img}")
print("------------------")

adjusted_img_np = F.adjust_brightness(img_arr, brightness_factor=2.0)
adjusted_img_tensor = F.adjust_brightness(tensor_img, brightness_factor=2.0)
print(f"np.array output: {adjusted_img_np}, dtype: {adjusted_img_np.dtype}")
print(f"paddle tensor output: {adjusted_img_tensor}, dtype: {adjusted_img_tensor.dtype}")

Output:

np.array input: [[[1.]]]
paddle tensor input: Tensor(shape=[1, 1, 1], dtype=float32, place=Place(cpu), stop_gradient=True,
       [[[1.]]])
------------------
np.array output: [[[2]]], dtype: uint8
paddle tensor output: Tensor(shape=[1, 1, 1], dtype=float32, place=Place(cpu), stop_gradient=True,
       [[[1.]]]), dtype: paddle.float32

Expected output:

np.array input: [[[1.]]]
paddle tensor input: Tensor(shape=[1, 1, 1], dtype=float32, place=Place(cpu), stop_gradient=True,
       [[[1.]]])
------------------
np.array output: [[[2]]], dtype: uint8
paddle tensor output: Tensor(shape=[1, 1, 1], dtype=float32, place=Place(cpu), stop_gradient=True,
       [[[2.]]]), dtype: paddle.float32

其他补充信息 Additional Supplementary Information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions