-
Notifications
You must be signed in to change notification settings - Fork 610
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 python fallback for adjust_hsv_in_yiq #2392
Add python fallback for adjust_hsv_in_yiq #2392
Conversation
) | ||
# Construct hsv linear transformation matrix in YIQ space. | ||
# https://beesbuzz.biz/code/hsv_color_transforms.php | ||
yiq = tf.constant( |
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.
Have you tested if it will be slower using https://www.tensorflow.org/api_docs/python/tf/image/rgb_to_yiq ?
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.
Some slowdown. I observe there are some redundant ops being used in tf.image.rgb_to_yiq
and tf.image.yiq_to_rgb
.
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.
Ok this is similar to https://github.com/tensorflow/tensorflow/blob/v2.4.1/tensorflow/python/ops/image_ops_impl.py#L2465-L2529
But as I see that has only native ops..
) | ||
transform_matrix = yiq @ hsv_transform @ yiq_inverse | ||
|
||
image = image @ transform_matrix |
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.
Do we need to support other dtypes
as in https://github.com/tensorflow/tensorflow/blob/v2.4.1/tensorflow/python/ops/image_ops_impl.py#L2522-L2525 ?
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.
Thanks for reminding! That's reasonable, maybe let me do it in the next PR?
Description
Adds python fallback for adjust_hsv_in_yiq. It's just a simple matmul, I do not see any performance regression when switching to python.
Type of change
Checklist:
How Has This Been Tested?
Passes existing tests.