I use tensorflow-models/mobilenet for application Reat native of me. The application works well when there is a network. But when the device is offline, on IOS applications it does not load model.
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 Error on iOS:
error : network request failed. But on Android, my application works well.
https://stackoverflow.com/questions/66765231/tensorflow-models-mobilenet-not-working-when-device-offline March 23, 2021 at 10:31PM
没有评论:
发表评论