rhdeck / react-native-coreml

CoreML module for React native
MIT License
36 stars 7 forks source link

Any example #2

Open rachit2jain opened 5 years ago

rachit2jain commented 5 years ago

Hi, I have been trying to use the library but I am not able to load the model using compileModel. The app just is stuck there and no response is given. Any idea what the problem is? Also, it will be really helpful if you could provide some example code? Thanks in advance!

rhdeck commented 5 years ago

Can you share a sample of what you are trying to do?

rhdeck commented 5 years ago

Also, not clear what example you are looking for - something beyond the snippet in the readme?

rachit2jain commented 5 years ago

Yes please - a code snippet would be very helpful especially how to load the model.

Sent from my iPhone

On 6 Nov 2018, at 6:15 AM, Ray Deck notifications@github.com wrote:

Also, not clear what example you are looking for - something beyond the snippet in the readme?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

rhdeck commented 5 years ago

I am not sure what you mean by load. Maybe if you were to share a snippet of code giving you trouble I could get a frame of reference to help you from.

rachit2jain commented 5 years ago

Load as in compile.

I imported the compileModel from ‘react-native-coreml’

Then I’m trying to compile the model using compileModel command.

import { compileModel } from ‘react-native-coreml’ onClassification = async => { const modelPath = await compileModel(‘../models/xyz.mlmodel’) } It returns me an error - evaluating RNModel.compileModel: undefined is not an object.

Sent from my iPhone

On 6 Nov 2018, at 9:11 AM, Ray Deck notifications@github.com wrote:

I am not sure what you mean by load. Maybe if you were to share a snippet of code giving you trouble I could get a frame of reference to help you from.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

matthewlui commented 5 years ago

To library author, you should state that, the path you need to init the model, is a "ABSOLUTE PATH" instead of a relative path that I think normal user will always expect. This guy obviously pass inside a relative path... @rhdeck @rachit2jain find an absolute path of that model and pass inside, work like a charm

rhdeck commented 5 years ago

Thank you l! That is helpful. On Thu, Nov 15, 2018 at 5:08 AM Matth3w Lui notifications@github.com wrote:

To library author, you should state that, the path you need to init the model, is a "ABSOLUTE PATH" instead of a relative path that I think normal user will always expect. This guy obviously pass inside a relative path... @rhdeck https://github.com/rhdeck @rachit2jain https://github.com/rachit2jain find an absolute path of that model and pass inside, work like a charm

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/rhdeck/react-native-coreml/issues/2#issuecomment-438987100, or mute the thread https://github.com/notifications/unsubscribe-auth/ALov_wNwBjp8JVxOq_kDmvd8grOcbcdNks5uvT03gaJpZM4YOBs6 .

rhdeck commented 5 years ago

I would love to know what path was being passed - if there is a common reference point the lib might be able to normalize it.

On Thu, Nov 15, 2018 at 6:19 AM Ray Deck ray@raydeck.com wrote:

Thank you l! That is helpful. On Thu, Nov 15, 2018 at 5:08 AM Matth3w Lui notifications@github.com wrote:

To library author, you should state that, the path you need to init the model, is a "ABSOLUTE PATH" instead of a relative path that I think normal user will always expect. This guy obviously pass inside a relative path... @rhdeck https://github.com/rhdeck @rachit2jain https://github.com/rachit2jain find an absolute path of that model and pass inside, work like a charm

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/rhdeck/react-native-coreml/issues/2#issuecomment-438987100, or mute the thread https://github.com/notifications/unsubscribe-auth/ALov_wNwBjp8JVxOq_kDmvd8grOcbcdNks5uvT03gaJpZM4YOBs6 .

matthewlui commented 5 years ago

My suggestion is, add a extra function which allow user to specify a bundle resource since I think it will hit most of the use case. Since on react native abstract level, I think not much user too understand how to play around the sandboxing file system, also, with a local model file but not download on the flight. Also, in the example, I would suggest not to use the "download example" since it's although it imply an absolute path, but maybe it will be better to tell it more explicitly

rhdeck commented 5 years ago

Thank you those are both good advice. Can I ask you to file them as issues so commits can map to them?

On Thu, Nov 15, 2018 at 10:28 AM Matth3w Lui notifications@github.com wrote:

My suggestion is, add a extra function which allow user to specify a bundle resource since I think it will hit most of the use case. Since on react native abstract level, I think not much user too understand how to play around the sandboxing file system, also, with a local model file but not download on the flight. Also, in the example, I would suggest not to use the "download example" since it's although it imply an absolute path, but maybe it will be better to tell it more explicitly

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/rhdeck/react-native-coreml/issues/2#issuecomment-439079666, or mute the thread https://github.com/notifications/unsubscribe-auth/ALov_yMCyuDP-qAiztib8jwQ3a0fm7fzks5uvYgLgaJpZM4YOBs6 .

rachit2jain commented 5 years ago

Thank you so much guys for your help. I have successfully compiled the model. I am trying to use classifyImage function but I am not getting anything back from the library. So I tried looking into the library and found an EXC_BREAKPOINT error in line let handler = VNImageRequestHandler(ciImage: image!) So I checked the source URL of the image file and it is right. Upon further investigation , the variable image is nil but imageURL is right. I even tried to use guard but still image is nil.

The imageURL is something like this file:///var/mobile/Containers/Data/Application/DE489179-DEFF-4D27-AC2D-1AF1445C6EF1/Library/Caches/Camera/FCB57CD1-6DFF-45FF-B8FA-A09FC77B1C32.jpg

davidpfahler commented 4 years ago

An example app would really help. The instruction in the README leave a lot of room for mistakes, many of which I am apparently making:

I am getting the following error as displayed in the iPhone simulator: TypeError: null is not an object (evaluating 'RNCoreML.mainBundlePath') and the first item in the stack trace point to line 14 in index.js of this project:

const { mainBundlePath, mainBundleURL } = RNCoreML;

Also, I would very much appreciate it if you could provide an example of loading the .mlmodel file from the bundle instead of downloading it from the web.

Thank you very much in advance.

chase-robbins commented 3 years ago

To library author, you should state that, the path you need to init the model, is a "ABSOLUTE PATH" instead of a relative path that I think normal user will always expect. This guy obviously pass inside a relative path... @rhdeck @rachit2jain find an absolute path of that model and pass inside, work like a charm

This should be added to the readme.