-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
how to use with local img #15
Comments
You need some way to get an Image's raw data as a number array (raw bytes). Not sure if fetch can do that in react native? |
I just remembered I have a lib for that, lol. Sometimes I forget what I build.
const imageResource = await fetch("file://mylocalimage.png")
const blob = await imageResource.blob()
const arrayBuffer = getArrayBufferForBlob(blob)
// make sure the model is appropriately sized and in RGBA though.
// otherwise, create a for loop that modifies the arrayBuffer so it fits the model.
await model.run([arrayBuffer]) |
@mrousavy await model.run([arrayBuffer]) returns array buffers |
|
for me react-native-blob-jsi-helper was not working. The array length was not correct so I created simple library https://github.com/marcinkornek/react-native-image-to-rgb to convert image to rgb array which is working fine. |
@marcinkornek how to give input format to this? like my model accepts 320 x 320 input |
@mashad6 I was using https://github.com/bamlab/react-native-image-resizer to resize image. You can do it with:
btw I'll add example with react-native-fast-tflite to my library :) |
@marcinkornek @mrousavy my tensor input shape is [1, 640, 640, 3] and output shape is [1, 7, 8400] and model require Float32Array buffer. `
But it shows an error that : Input Buffer size (2764800) does not match the Input Tensor's expected size (4915200)! Make sure to resize the input values accordingly. how to do that resizing in this code. please suggest. |
I am working with img labling project and need guidance on processing local images from the file system. How can I convert these local image files into tensors to pass them as inputs to the functions? and im using expo and it seems like @tensorflow/tfjs-react-native doesnt work with the currunt version of expo
The text was updated successfully, but these errors were encountered: