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 python fallback for adjust_hsv_in_yiq #2392

Merged

Conversation

WindQAQ
Copy link
Member

@WindQAQ WindQAQ commented Feb 15, 2021

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:

  • I've properly formatted my code according to the guidelines
    • By running Black + Flake8
    • By running pre-commit hooks
  • This PR addresses an already submitted issue for TensorFlow Addons
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • This PR contains modifications to C++ custom-ops

How Has This Been Tested?

Passes existing tests.

)
# Construct hsv linear transformation matrix in YIQ space.
# https://beesbuzz.biz/code/hsv_color_transforms.php
yiq = tf.constant(
Copy link
Contributor

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 ?

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

@WindQAQ WindQAQ requested a review from bhack February 16, 2021 03:23
)
transform_matrix = yiq @ hsv_transform @ yiq_inverse

image = image @ transform_matrix
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

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?

@WindQAQ WindQAQ merged commit 95055be into tensorflow:master Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants