`to_pil_image` rounds down
Open
Beginner friendly
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 17.9k
- Forks
- 7.3k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 13
Description
🐛 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the to_pil_image entry point and reproduce the reported conversion with the provided PyTorch example. Inspect the existing tests around this conversion, then verify that an input of 0.9999 produces 255 rather than 254 and that existing behavior remains covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100