Setting `-5` and `5` to `sharpness_factor` argument of `RandomAdjustSharpness()` sharpens and blurs images respectively
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 17.9k
- Forks
- 7.3k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 13
Description
📚 The doc issue
The doc of RandomAdjustSharpness() says below:
Adjust the sharpness of the image or video with a given probability.
...
Parameters:
- sharpness_factor (float) – How much to adjust the sharpness. Can be any non-negative number. 0 gives a blurred image, 1 gives the original image while 2 increases the sharpness by a factor of 2.
But setting -5 and 5 to sharpness_factor argument of RandomAdjustSharpness() sharpens and blurs images respectively as shown below:
from torchvision.datasets import OxfordIIITPet
from torchvision.transforms.v2 import RandomAdjustSharpness
sfn5p1_data = OxfordIIITPet( # `sf` is sharpness_factor.
root="data", # `n` is negative.
transform=RandomAdjustSharpness(sharpness_factor=-5, p=1)
)
sf1p1origin_data = OxfordIIITPet(
root="data",
transform=RandomAdjustSharpness(sharpness_factor=1, p=1)
)
sf5p1_data = OxfordIIITPet(
root="data",
transform=RandomAdjustSharpness(sharpness_factor=5, p=1)
)
import matplotlib.pyplot as plt
def show_images(data, main_title=None):
plt.figure(figsize=[10, 5])
plt.suptitle(t=main_title, y=0.8, fontsize=14)
for i, (im, _) in zip(range(1, 6), data):
plt.subplot(1, 5, i)
plt.imshow(X=im)
plt.xticks(ticks=[])
plt.yticks(ticks=[])
plt.tight_layout()
plt.show()
show_images(data=sfn5p1_data, main_title="sfn5p1_data")
show_images(data=sf1p1origin_data, main_title="sf1p1origin_data")
show_images(data=sf5p1_data, main_title="sf5p1_data")
Suggest a potential alternative/fix
So, the doc of RandomAdjustSharpness() should say something like below:
Sharpen or blur an image or video with a given probability.
...
Parameters:
- sharpness_factor (float) – How much to adjust the sharpness. Can be any negative or non-negative number.
x < 1gives a blurred image,1gives the original image while1 < xgives a sharpened image.
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 linked RandomAdjustSharpness API documentation and its sharpness_factor parameter description; compare it with the examples and proposed wording in the issue. Done when the docs accurately describe negative, zero, one, and greater-than-one factors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- computer-vision, documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100