Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gamma invert transform #1309

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

take5v
Copy link

@take5v take5v commented Oct 11, 2022

Extend RandomGamma transform with invert gamma, which is applied with p_invert probability.

Comment on lines +794 to +795
else:
img = 1 - np.power(1 - img, gamma)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think better to take max value from MAX_VALUES_BY_DTYPE because img might have int32 dtype

@@ -1371,6 +1371,8 @@ class RandomGamma(ImageOnlyTransform):
Args:
gamma_limit (float or (float, float)): If gamma_limit is a single float value,
the range will be (-gamma_limit, gamma_limit). Default: (80, 120).
p_invert (float): Probability of applying transform symmetrical to gamma transform with respect to the y=x.
Identical to sequentially applied InvertImg, RandomGamma and InvertImg. Default: 0.0.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think would be great add there link to the issue or to the article directly

return {
"gamma": random.uniform(self.gamma_limit[0], self.gamma_limit[1]) / 100.0,
"invert": random.random() > self.p_invert,
}

def get_transform_init_args_names(self):
return ("gamma_limit", "eps")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add p_invert to get_transform_init_args_names

return {"gamma": random.uniform(self.gamma_limit[0], self.gamma_limit[1]) / 100.0}
return {
"gamma": random.uniform(self.gamma_limit[0], self.gamma_limit[1]) / 100.0,
"invert": random.random() > self.p_invert,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect condition. Must be random.random() < self.p_invert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants