tfjs icon indicating copy to clipboard operation
tfjs copied to clipboard

tfjs-tflite: iOS Out of memory error with Cross-Origin Policy

Open Jove125 opened this issue 1 year ago • 0 comments

Hi,

According to this recomendations, it is necessary setting up cross-origin isolation: https://github.com/tensorflow/tfjs/tree/master/tfjs-backend-wasm#setting-up-cross-origin-isolation

Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp

After these settings, neural networks on a desktop PC and on android devices begin to work much faster. But the following error occurs on the iPhone (tested on iPhone 6S and 13 Max Pro). How can it be avoided?

Unhandled Promise Rejection: RangeError: Out of memory
promiseEmptyOnRejected — tflite_web_api_cc_threaded.js:287
promiseReactionJob

0

if to remove the server cross-origin settings, then everything works on the iPhone, but slowly.

html code to reproduce error:

<script src="./node_modules/@tensorflow/tfjs-core/dist/tf-core.min.js"></script>
<script src="./node_modules/@tensorflow/tfjs-backend-cpu/dist/tf-backend-cpu.min.js"></script>
<script src="./node_modules/@tensorflow/tfjs-tflite/dist/tf-tflite.min.js"></script>

<script>
var promise = tflite.loadTFLiteModel(modelPath, {numThreads: 4});
</script>

Jove125 avatar Jan 28 '24 21:01 Jove125