Skip to content

Phase 4: Transform Correctness#5

Merged
ALJainProjects merged 1 commit into
mainfrom
phase4/transform-correctness
Feb 9, 2026
Merged

Phase 4: Transform Correctness#5
ALJainProjects merged 1 commit into
mainfrom
phase4/transform-correctness

Conversation

@ALJainProjects
Copy link
Copy Markdown
Owner

Summary

  • Color jitter contrast: Fix to use per-channel mean instead of global mean across all channels, matching torchvision's behavior. The old code computed a single average across R/G/B, causing incorrect color shifts during contrast adjustment.
  • Bilinear interpolation: Fix boundary clamping order — clamp x0/y0 before computing x1/y1 and fractional parts. The old code could read 1 pixel out of bounds at image edges with negative source coordinates. Also clamp dx/dy to [0,1] to prevent extrapolation artifacts.

Test plan

  • Added per-channel contrast test: R/G/B means stay near original values (not dragged toward global mean)
  • Added bilinear boundary safety test: negative coords, beyond-bounds coords, exact corners, center interpolation

Color jitter:
- Fix contrast to use per-channel mean instead of global mean across all
  channels, matching torchvision's behavior. This was causing incorrect
  contrast adjustments that shift all channels toward a single average,
  producing color shifts during training.

Bilinear interpolation:
- Fix boundary clamping order: clamp x0/y0 before computing x1/y1 and
  fractional parts. The old code computed x1 from unclamped x0, which
  could read 1 pixel out of bounds at image edges with negative source
  coordinates.
- Clamp dx/dy to [0,1] to prevent extrapolation artifacts.

Tests:
- Add per-channel contrast test verifying R/G/B means stay near their
  original values (not dragged toward a global mean)
- Add bilinear boundary safety test with negative coords and beyond-bounds
@ALJainProjects ALJainProjects merged commit 595e48e into main Feb 9, 2026
7 checks passed
@ALJainProjects ALJainProjects deleted the phase4/transform-correctness branch February 9, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant