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

[Question] Blob Tensor Format #32

Closed
wuassassin opened this issue Mar 23, 2022 · 3 comments
Closed

[Question] Blob Tensor Format #32

wuassassin opened this issue Mar 23, 2022 · 3 comments

Comments

@wuassassin
Copy link

Hello @abrown, I'm interested in contributing example codes to this repo, especially for issue #7. But I'm not familiar with the .bgr file in the fixtures folder. Is it compatible with https://github.com/bytecodealliance/wasi-nn/tree/main/image2tensor?

@abrown
Copy link
Contributor

abrown commented Mar 23, 2022

Thanks for taking a look at #7! Your contributions would be appreciated. Now, about compatibiliy, I am not completely sure but let me share what I think. The .bgr files in this repository were created with the openvino-tensor-converter tool which I developed as a helper for the test fixtures you mention. Here's an example of how it is used in one of the build.sh scripts that attempts to regenerate the fixture artifacts:

cargo run -p openvino-tensor-converter -- $TMP_DIR/val2017/000000062808.jpg $FIXTURE_DIR/tensor-1x3x227x227-f32.bgr 227x227x3xfp32

Images need to be decoded to perform the inference and the openvino-tensor-converter uses OpenCV as the library to do the conversions--IIRC, I ran into issues where I could not seem to generate the right raw bytes and using OpenCV fixed this (I think this is also what OpenVINO uses internally if one asks it to do the conversions). I found it more clear to create separate .bgr files for these decoded bytes but I could have just as well decoded the bytes in memory using the lib.rs functions.

The image2tensor library does essentially the same thing: it decodes images into the right bytes for a tensor. The differences are that it uses the image library instead of OpenCV and it only handles f32 precision at the moment, I believe. And the purpose of the tools is slightly different: openvino-tensor-converter is made for this repository's tests (a small scope!) whereas image2tensor is intended for anyone who might need to convert images to tensors in WebAssembly-compiled code. @brianjjones, any other comments on differences or similarities?

Bottom line, in my opinion, is that you're better off taking a crack at this with openvino-tensor-converter at the moment. It's probably the path of least resistance for contributing to this repository.

@wuassassin
Copy link
Author

wuassassin commented Mar 24, 2022

Bottom line, in my opinion, is that you're better off taking a crack at this with openvino-tensor-converter at the moment. It's probably the path of least resistance for contributing to this repository.

Cool will do 👍🏼

Anyway, can we close this issue after I tried image2tensor? (or perhaps after @brianjjones clarify the inquiry)

@abrown
Copy link
Contributor

abrown commented Oct 3, 2024

It's been a while since this has opened and the situation has not changed much. @wuassassin, I'll close it for now but feel free to reopen it if there are further questions along these lines.

@abrown abrown closed this as completed Oct 3, 2024
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

No branches or pull requests

2 participants