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

Improve PIL and COLOR_BGR context image decode performance #1501

Merged

Conversation

vinnamkim
Copy link
Contributor

@vinnamkim vinnamkim commented May 16, 2024

Summary

  • Ticket no. 141409
  • There was a significant performance degradation on decode_by_pil() if ImageColorChannel.COLOR_BGR.
  • Improve it by returning a numpy array rather than PIL.Image and using cv2.cvtColor() rather than np.flip().

How to test

  • tests/unit/test_image.py covers this change.
  • Compare performance with this code (dataset: Imagenette2)
before after
image image
00:51<00:00, 361.65it/s 00:19<00:00, 859.39it/s

Checklist

  • I have added unit tests to cover my changes.​
  • I have added integration tests to cover my changes.​
  • I have added the description of my changes into CHANGELOG.​
  • I have updated the documentation accordingly

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.
  • I have updated the license header for each file (see an example below).
# Copyright (C) 2024 Intel Corporation
#
# SPDX-License-Identifier: MIT

@vinnamkim vinnamkim requested review from a team as code owners May 16, 2024 08:10
@vinnamkim vinnamkim requested review from itrushkin and removed request for a team May 16, 2024 08:10
@vinnamkim vinnamkim changed the title Improve PIL image decode performance with COLOR_BGR context Improve PIL and COLOR_BGR context image decode performance May 16, 2024
Copy link

codecov bot commented May 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (releases/1.7.0@4394c6a). Learn more about missing BASE report.

Additional details and impacted files
@@                Coverage Diff                @@
##             releases/1.7.0    #1501   +/-   ##
=================================================
  Coverage                  ?   80.78%           
=================================================
  Files                     ?      276           
  Lines                     ?    31485           
  Branches                  ?     6345           
=================================================
  Hits                      ?    25435           
  Misses                    ?     4639           
  Partials                  ?     1411           
Flag Coverage Δ
ubuntu-20.04_Python-3.10 80.77% <100.00%> (?)
windows-2022_Python-3.10 80.75% <100.00%> (?)

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.

Copy link
Contributor

@wonjuleee wonjuleee left a comment

Choose a reason for hiding this comment

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

Great work! Could you target this PR to releases/1.7.0?

@vinnamkim vinnamkim changed the base branch from develop to releases/1.7.0 May 17, 2024 04:23
@vinnamkim vinnamkim force-pushed the improve-perf-decode-by-pil branch 2 times, most recently from 74911b8 to 51952ed Compare May 17, 2024 05:37
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
@vinnamkim
Copy link
Contributor Author

Rebased and targeted to releases/1.7.0

@vinnamkim vinnamkim merged commit 3501e97 into openvinotoolkit:releases/1.7.0 May 17, 2024
8 checks passed
@vinnamkim vinnamkim deleted the improve-perf-decode-by-pil branch May 17, 2024 06:37
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.

2 participants