Skip to content

[OpenVINO] Implement image transforms (affine, perspective, elastic)#22696

Merged
hertschuh merged 5 commits intokeras-team:masterfrom
goyaladitya05:openvino/transforms
Apr 20, 2026
Merged

[OpenVINO] Implement image transforms (affine, perspective, elastic)#22696
hertschuh merged 5 commits intokeras-team:masterfrom
goyaladitya05:openvino/transforms

Conversation

@goyaladitya05
Copy link
Copy Markdown
Contributor

Description

This PR implements affine_transform, perspective_transform, and elastic_transform for the OpenVINO backend.

  • affine_transform: builds transformed coords via OV range/broadcast/matmul, right-multiplies pts @ T + offset per the scipy convention, then delegates to map_coordinates
  • perspective_transform: solves the 8×8 system via ov_opset.inverse, applies the projective warp formula per output pixel
  • elastic_transform: generates random displacement fields with Box-Muller sampling, smooths with gaussian_blur, then displaces coords before sampling

Removed 50 tests, which now pass after these implementations.

Closes: openvinotoolkit/openvino/issues/35412

Contributor Agreement

Please check all boxes below before submitting your PR for review:

  • I am a human, and not a bot.
  • I will be responsible for responding to review comments in a timely manner.
  • I will work with the maintainers to push this PR forward until submission.

Note: Failing to adhere to this agreement may result in your future PRs no longer being reviewed.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements affine_transform, perspective_transform, and elastic_transform for the OpenVINO backend, enabling several previously excluded image operation tests. The implementation uses OpenVINO opsets for coordinate mapping and homography computation. Feedback identifies a hardcoded fill_mode in perspective_transform that should be parameterized for API consistency, a docstring error regarding return dimensions, and opportunities to optimize coordinate gathering. Additionally, the review suggests improving robustness against division-by-zero in projective transformations and notes a performance bottleneck in elastic_transform due to a symbolic-to-NumPy conversion during seeding.

Comment thread keras/src/backend/openvino/image.py
Comment thread keras/src/backend/openvino/image.py Outdated
Comment thread keras/src/backend/openvino/image.py Outdated
Comment thread keras/src/backend/openvino/image.py
Comment thread keras/src/backend/openvino/image.py
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 18, 2026

Codecov Report

❌ Patch coverage is 92.77108% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.68%. Comparing base (e5c9a6e) to head (82088c6).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
keras/src/backend/openvino/image.py 92.77% 12 Missing and 12 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #22696      +/-   ##
==========================================
- Coverage   78.82%   77.68%   -1.15%     
==========================================
  Files         596      596              
  Lines       69293    69625     +332     
  Branches    10829    10861      +32     
==========================================
- Hits        54622    54089     -533     
- Misses      11941    12781     +840     
- Partials     2730     2755      +25     
Flag Coverage Δ
keras 77.59% <92.77%> (-1.10%) ⬇️
keras-jax 58.43% <2.10%> (?)
keras-numpy 54.28% <0.00%> (-0.26%) ⬇️
keras-openvino 59.68% <92.77%> (+0.25%) ⬆️
keras-tensorflow 59.98% <2.10%> (-0.28%) ⬇️
keras-torch ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@goyaladitya05 goyaladitya05 marked this pull request as ready for review April 19, 2026 17:19
Copy link
Copy Markdown
Collaborator

@hertschuh hertschuh left a comment

Choose a reason for hiding this comment

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

Thanks for implementing these!

@google-ml-butler google-ml-butler Bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Apr 20, 2026
@google-ml-butler google-ml-butler Bot removed the ready to pull Ready to be merged into the codebase label Apr 20, 2026
@hertschuh hertschuh merged commit 1548345 into keras-team:master Apr 20, 2026
10 of 11 checks passed
@goyaladitya05 goyaladitya05 deleted the openvino/transforms branch April 21, 2026 03:08
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.

[Keras 3 OpenVINO backend] Support (affine, perspective, elastic) image transforms

4 participants