From 08956dd5f1435e1af6f843948acc25a2d7170369 Mon Sep 17 00:00:00 2001 From: Zul Ikram Musaddik Rayat <2010050@me.buet.ac.bd> Date: Thu, 23 Jan 2025 00:57:59 +0600 Subject: [PATCH] Bug fix (tfjs-react-native): fallback to lodalUri when uri in unavailable in bundleResourceIO --- tfjs-react-native/src/bundle_resource_io.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tfjs-react-native/src/bundle_resource_io.ts b/tfjs-react-native/src/bundle_resource_io.ts index 06d1fa26f12..846e3c92dab 100644 --- a/tfjs-react-native/src/bundle_resource_io.ts +++ b/tfjs-react-native/src/bundle_resource_io.ts @@ -103,7 +103,7 @@ class BundleResourceHandler implements io.IOHandler { if (Platform.OS === 'android') { // On android we get a resource id instead of a regular path. We // need to load the weights from the res/raw folder using this id. - const fileName = `${weightsAsset.uri}.${weightsAsset.type}`; + const fileName = weightsAsset.uri ? `${weightsAsset.uri}.${weightsAsset.type}` : weightsAsset.localUri; try { base64Weights = await RNFS.readFileRes(fileName, 'base64'); } catch (e) { @@ -114,7 +114,7 @@ class BundleResourceHandler implements io.IOHandler { } } else { try { - base64Weights = await RNFS.readFile(weightsAsset.uri, 'base64'); + base64Weights = await RNFS.readFile(weightsAsset.uri ?? weightsAsset.localUri, 'base64'); } catch (e) { throw new Error( `Error reading resource ${weightsAsset.uri}.`,