Skip to content

to_pil_image rounds down #8141

Description

@rb-synth

🐛 Describe the bug

The current code is: pic = pic.mul(255).byte().

If the input is, say, 0.9999, this will be rounded down to 254 instead of 255.

>>> torch.as_tensor([0.9999]).mul(255).byte().item()
254

I would suggest that the code be: pic = pic.mul(255).round().byte():

>>> torch.as_tensor([0.9999]).mul(255).round().byte().item()
255

Versions

N/A

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions