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

Added support for native image decoding #808

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

skyline75489
Copy link
Collaborator

@skyline75489 skyline75489 commented Sep 13, 2024

This added support for native image decoding on Windows & Apple platforms. This helps us remove libpng & libjpeg completely on these platforms, and in the meantime support more image formats thanks to OS vendors,


ASSERT_EQ(out_tensor.Shape(), std::vector<int64_t>({876, 1300, 3}));
auto out_range = out_tensor.Data() + 0;
ASSERT_EQ(std::vector<uint8_t>(out_range, out_range + 12),
std::vector<uint8_t>({48, 14, 5, 48, 14, 5, 48, 14, 5, 48, 14, 5}));

#if OCOS_ENABLE_VENDOR_IMAGE_CODECS
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The implementation difference results in tiny difference in the decoding result

}

#if OCOS_ENABLE_VENDOR_IMAGE_CODECS
TEST(ImageDecoderTest, TestTiffDecoder) {
Copy link
Collaborator Author

@skyline75489 skyline75489 Sep 13, 2024

Choose a reason for hiding this comment

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

This is just an example. Many other formats will be supported as long as the OS provides such capability.

optionKeys[0] = kCGImageSourceShouldCache;
optionValues[0] = (CFTypeRef)kCFBooleanFalse;
// Only Integer image data is currently supported
optionKeys[1] = kCGImageSourceShouldAllowFloat;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will we add support for float numbe image? I'm not sure about this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@skyline75489 skyline75489 marked this pull request as ready for review September 14, 2024 01:19
@skyline75489 skyline75489 requested a review from a team as a code owner September 14, 2024 01:19
@@ -71,6 +71,7 @@ option(OCOS_ENABLE_BERT_TOKENIZER "Enable the BertTokenizer building" ON)
option(OCOS_ENABLE_BLINGFIRE "Enable operators depending on the Blingfire library" ON)
option(OCOS_ENABLE_MATH "Enable math tensor operators building" ON)
option(OCOS_ENABLE_DLIB "Enable operators like Inverse depending on DLIB" ON)
option(OCOS_ENABLE_VENDOR_IMAGE_CODECS "Enable and use vendor image codecs if supported over libpng & libjpeg" ON)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure this should be enabled by default.

return status;
}

~DecodeImage() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is destructor the correct place to release resources?

@skyline75489
Copy link
Collaborator Author

To reviewers: I'll be out of office next week. Feel free to modify my branch directly.

@skottmckay
Copy link
Contributor

For pre/post processing we use the DecodeImage and EncodeImage operators. Is there a plan to add native encoding as well?

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.

3 participants