I'm trying to follow the 'Usage' example in this repo: https://github.com/rhdeck/react-native-coreml
So my code is fairly similar:
const coreml = async (pathToImage: string) => { try { const {jobId, promise} = RNFS.downloadFile({ fromUrl: NetworkMLModelPath, toFile: `${RNFS.DocumentDirectoryPath}MobileNetV2.mlmodel`, }); await promise; console.log('jobId', jobId); const [{name, path, isFile, isDirectory}] = await RNFS.readDir( `${RNFS.DocumentDirectoryPath}`, ); console.log('name', name, 'path', path, isFile(), isDirectory()); const modelPath = await compileModel(path); // const {label, confidence} = await classifyTopValue(pathToImage, modelPath); // console.log('The image is a '+ label +'. I think. '); } catch (error) { console.log(error); }};
And my output is
LOG jobId 1 LOG name MobileNetV2.mlmodel path /var/mobile/Containers/Data/Application/4A549020-958B-4B83-99EE-782E4DAAEA9C/Documents/MobileNetV2.mlmodel true false ERROR TypeError: null is not an object (evaluating 'RNCoreML.mainBundlePath') LOG [TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[6], "react-native-coreml").compileModel')]
So my RNFS.downloadFile() seems to have worked since I have a jobId, but I don't have a path to my file since my file "doesn't exist". Any help or suggestions would be appreciated!