0

I'm trying to build an app that uses yolov5 (basically object detection). the inference results are the same as python when i use my samsung galaxy fold 3. however when i start using it on my iphone, the results starts becoming very random. for the same image, i got the following:

Android

Array [
  Array [
    0.89697265625,
    0.928567626953125,
    0.77938091283,
    0.83837890625,
    0.99128372305,
    0.9267578125,
    0.27389136875,
    0.938228374,
    -1,
    -1,
    -1,
    -1,
    -1,
    -1,
    -1,
    -1,
    -1,
    -1,
    -1,
    -1,
  ],
]

but on iOS its

Array [
  Array [
    0.97612903,
    0.01050567626953125,
    0.0007758140563964844,
    0.83837890625,
    0.276123046875,
    0.9267578125,
    0.00025463104248046875,
    0.000011324882507324219,
    -1,
    -1,
    -1,
    -1,
    -1,
    -1,
    -1,
    -1,
    -1,
    -1,
    -1,
    -1,
  ],
]

I found a github issue that says to do tf.ENV.set('WEBGL_PACK', false) but it did not help. apparently it's a webgl issue(?)

a snippet of my prediction function

const onReady = React.useCallback(
    (images) => {
      const loop = async () => {
        // const nextImageTensor = images.next().value;
        const nextImageTensor = tf.cast(images.next().value.reverse(1).reverse(-1).expandDims(0), 'float32').div(tf.scalar(255.0, "float32"));
        const predictions = await model.executeAsync(nextImageTensor);
        setPredictions({
          predictions: predictions,
          img: nextImageTensor
        });
        camRef.current = requestAnimationFrame(loop);
      };
      loop()
      // .catch((e) => {
      //   console.log("Caught error!")
      // })
    },
    [setPredictions]

any help would be greatly appreciated!

4

0 回答 0