React native tensorflow型号/mobilenet在设备脱机时不工作
我使用tensorflow models/mobilenet作为我自己的应用程序。 当有网络时,应用程序运行良好。但当设备离线时,在IOS应用程序上它不会加载模型React native tensorflow型号/mobilenet在设备脱机时不工作,react-native,tensorflow.js,React Native,Tensorflow.js,我使用tensorflow models/mobilenet作为我自己的应用程序。 当有网络时,应用程序运行良好。但当设备离线时,在IOS应用程序上它不会加载模型 async function predictMobilenet() { try { setTextshow(' LOADING...') var start = new Date().getTime(); console.log(' Load m
async function predictMobilenet() {
try {
setTextshow(' LOADING...')
var start = new Date().getTime();
console.log(' Load model...')
//const tfReady = await tf.ready();
const tfReady = await tf.ready();
console.log('Uffect load model')
const model = await mobilenet.load();
const imgB64 = await FileSystem.readAsStringAsync(selectedImage.localUri, {
encoding: FileSystem.EncodingType.Base64,
});
const imgBuffer = tf.util.encodeString(imgB64, 'base64').buffer;
const raw = new Uint8Array(imgBuffer)
const imageTensor = decodeJpeg(raw);
const prediction = await model.classify(imageTensor);
var end = new Date().getTime();
var time = end - start;
setTextshow(JSON.stringify(prediction))
setTime(time)
}catch (e) {
setTextshow(e.toString())
console.log(e)
}
}
code line: const model = await mobilenet.load(); not working on ios when device offline
iOS上的错误:
error : network request failed.
但在Android上,我的应用程序运行良好