Custom IOHandler for TensorFlow.js that uses Capacitor's File System. Based on https://www.tensorflow.org/js/guide/save_load.
import * as tf from '@tensorflow/tfjs';
// Load
const customFileSystem = new CapacitorFileSystem(modelReference);
this.userModel = await tf.loadLayersModel(customFileSystem);
// Save
const customFileSystem = new CapacitorFileSystem(modelReference);
model.save(customFileSystem);
Where modelReference
is a valid path accepted by Capacitor's File System plugin.