Skip to content

Unable to use RNFS to read a file despite providing an absolute path #7

Description

@syedwshah

I'm trying to follow the 'Usage' example in this repo: https://github.com/rhdeck/react-native-coreml

So my code is fairly similar:

import {compileModel, classifyTopValue} from 'react-native-coreml';
const NetworkMLModelPath =
  'https://github.com/hollance/MobileNet-CoreML/raw/master/MobileNet.mlmodel';

const coreml = async (pathToImage: string) => {
  const path = 'MobileNetV2.mlmodel';
  try {
    const {promise} = await RNFS.downloadFile({
      fromUrl: NetworkMLModelPath,
      toFile: RNFS.MainBundlePath + path,
    });

    console.log('promise', (await promise).statusCode);

    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  [TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[5], "react-native-coreml").compileModel')]

So my RNFS.downloadFile() seems to have worked since I have a jobId and a statusCode 200, so I wonder why compileModel is going to error. Any help or suggestions would be appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions