3 unstable releases
0.2.0 | Nov 22, 2022 |
---|---|
0.1.1 | Oct 6, 2021 |
0.1.0 | Oct 6, 2021 |
#236 in WebAssembly
7KB
72 lines
Image2Tensor
This package provides several helper functions for converting images to tensors.
Use
calculate_buffer_size(width, height, precision)
: Given the width, height, and precision of your desired tensor, it will return the number of bytes you need to allocate. This is used to determine the size of the array you need to allocate for the output buffer you pass to convert_image.convert_image_to_bytes(path, width, height, precision, order)
: Will convert the image located at the path into a byte array with the requested dimensions and precision. NOTE: This currently only works with images that are in standard 8bit RGB color format.
Examples
use image2tensor;
let width: u32 = 224;
let height: u32 = 224;
let bytes = image2tensor::convert_image_to_bytes("path/to/file", width, height, TensorType::F32, ColorOrder::BGR);
License
This project is licensed under the Apache 2.0 license. See LICENSE for more details.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.
Dependencies
~5.5MB
~62K SLoC