Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix (tfjs-react-native): fallback to localUri when uri in unavailable in bundleResourceIO! #8504

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tfjs-react-native/src/bundle_resource_io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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}.`,
Expand Down