-
Notifications
You must be signed in to change notification settings - Fork 422
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
String tensor vs utf8 encoding #422
Comments
No need to check as valid utf-8, since the TensorFlow uses strings as byte buffer containers. How about using raw_ops::read_file if you want to decode it using this TensorFlow wrapper. https://github.com/tensorflow/rust/blob/master/examples%2Fmobilenetv3.rs#L38-L38 |
For my use case, the file is already in memory (received via network) so it would be wasteful to load it from disk with My concern with putting non-UTF8 character into a It feels like using a different type to represent the string data type might be more sensible, especially given the hoops required to convert a Rust byte container to a Rust |
As indicated by the namespace https://www.tensorflow.org/api_docs/python/tf/raw_ops/DecodeImage While it might be possible to wrap raw_ops to create a more Rust-like API, currently, nobody seems to have undertaken that effort. |
I've tried to convert a rank-1 tensor of dtype=uint8 to a rank-0 tensor of dtype=string using I think we actually need to introduce either Your concern about calling
|
I'm trying to use
raw_ops::decode_image
to load an image directly from au8
slice (as opposed to from file as per the example), but it seems I must first convert the slice to a scalar tensor string.It appears I can make this work with something like:
let s = unsafe { String::from_utf8_unchecked(image_bytes.to_vec()) };
My concern is that Rust expects all strings to be
utf8
encoded, of which the above certainly is not.Am I missing something obvious? Is there a better way to approach this?
The text was updated successfully, but these errors were encountered: