Read Native image format for object detection models

Hello All

I would like to use hustvl/yolos-tiny or another object detection model with React Native. I am having an issue with getting the image in the proper format for making a post request.

React Native does not support the Node file system module [as shown in the JavaScript example when deploying the model using the inference API serverless option].

I am using expo-file-system module.

When making the post request the format is not supported.

I would like to see if anyone has run into the same issue and has come up with a solution.

code I am using with expo-file-system

const img64 = await FileSystem.readAsStringAsync(uri, {
      encoding: FileSystem.EncodingType.Base64,
  });
  const imgBuffer = tf.util.encodeString(img64, "base64").buffer;
  const raw = new Uint8Array(imgBuffer);
  let imgTensor = decodeJpeg(raw);
  return img;

JavaScript example using Node readFileSync
image