-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
base: main
Are you sure you want to change the base?
Conversation
else: | ||
img = 1 - np.power(1 - img, gamma) |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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") |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
Extend RandomGamma transform with invert gamma, which is applied with p_invert probability.