-
-
Notifications
You must be signed in to change notification settings - Fork 791
Improve RMSE math and lower thresholds in Canvas tests #4011
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
Conversation
|
First of all, I know most of the core team's on holiday leave, so I'm aware this might not get reviewed for a while. @corranwebster, I'd appreciate a double-check on my math. I've changed how it's written out Python-wise, but math-wise the only differences should be, per your suggestions:
Evidently the premultiplying helps a lot in some cases. After all, dividing by bands should, alone, only halve the error amounts... but the threshold for the
|
corranwebster
left a comment
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.
Looks good, as a non-maintainer.
Maintainer or not, I very much appreciate your canvas-and-image-related expertise so far! |
johnzhou721
left a comment
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.
Nice use of ImageChops.difference!
Credit to corranwebster, they're the one who suggested it 👍 |
|
@HalfWhitt Please ping me when this is ready for review. Thanks! |
|
@kattni Ping : ) |
|
(This is still ready to go, I just decided to arrange it slightly differently.) |
freakboy3742
left a comment
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.
Can't argue with much here - ImageChops.difference() is a new one for me, but I'm very much in favor of adopting something that is a pre-existing difference measure than inventing one. And, if it means our error thresholds are lower, all the better.
Just for the record, ImageChops.difference is only a tidier way of doing the same math as what I initially submitted: total = sum(
((actual - expected) / 255) ** 2
for actual, expected in zip(
chain(*scaled_image.convert("RGBa").getdata()),
chain(*reference_image.convert("RGBa").getdata()),
strict=True,
)
)It's not relevant to lowering the error; that comes entirely from (1) dividing by the number of bands, and (2) premultiplying the alpha, so we're not testing invisible differences. (Both of which were corranwebster's idea on the original ticket). |
Fixes #4005; I've been nerd-sniped.
Uploading this with threshold values that work on macOS; presumably at least a couple will need bumping up a little depending on test failures.Also removes the unused
assert_pixel.PR Checklist: