Repository navigation
Conversation
Use the stride-2 downsampling factor when checking the last SSIM scale. Report the exact minimum size of the affected spatial dimension and add 2D and 3D boundary tests for one through six scales. Signed-off-by: Don Yin <Don_Yin@outlook.com> Assisted-by: Claude <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Description
I corrected the minimum-size check in
compute_ms_ssimto follow its stride-2 pooling. WithLscales, the final SSIM calculation sees each spatial dimension divided by2 ** (L - 1), notmax(1, L - 1) ** 2.The old check rejects valid four-scale inputs and lets undersized two-scale inputs reach a convolution error. With the default 11-pixel kernel:
ValueError.ValueErrorbefore convolution, with the correct minimum of 22 pixels.I also updated the error message to identify the affected spatial dimension and report its exact minimum. The SSIM calculation and weights are unchanged; the default five-scale size threshold is unchanged.
Evidence
I checked 96 combinations of square image size and scale count using identical synthetic images and the default kernel. For the feasibility panel, I disabled only the old size precheck and ran the actual pooling and convolution operations. The old gate falsely accepts five combinations and falsely rejects two; the fixed gate agrees with feasibility in all 96 combinations. Outlined cells mark disagreements in the old gate.
Types of changes
Validation
python -m unittest tests.metrics.test_compute_multiscalessim_metric tests.metrics.test_ssim_metric tests.losses.test_ssim_loss -v: 36 tests passed.black --check,isort --check-only, andruff checkpassed for both changed files.I used an AI coding assistant to help investigate and draft this; I reviewed and tested every change.