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

Custom model does not work #175

Open
lucksp opened this issue Nov 21, 2024 · 0 comments
Open

Custom model does not work #175

lucksp opened this issue Nov 21, 2024 · 0 comments

Comments

@lucksp
Copy link

lucksp commented Nov 21, 2024

I am trying to run my custom model as described in the docs, by defining the model name as part of the options passed to the hook that creates the provider:

const MODELS: AssetRecord = {
  // the name you'll use to refer to the model
  myCustomModel: { // <--- this is the name referenced later
    // the relative path to the model file
    asset: require("./assets/models/my-custom-model.tflite"),
    options: {
      // the options you want to use for this model
      shouldEnableMultipleObjects: false,
      shouldEnableClassification: false,
      detectorMode: "singleImage",
    },
  },
};

And then:

fetch the model from the hook, if you don't pass a model name it will fetch the default MLKit Object Detection model const { model } = useObjectDetector("myCustomModel");

I have also tried editing the Example app from useObjectDetector("myCustomModel"); to match the name of the custom model to : useObjectDetector("licensePlate");. Unfortunately, no images are detected, even if I take a picture of one of the ExampleApp license plate photos.

However, in the ExampleApp with the license plate detection, the useObjectDetector argument does not match: useObjectDetector("default")

I tried copying the model file to my own project assets/models/license-plate-detection.tflite" and it unfortunately does not return any results from this model:

{"detectionResult":[{"labels":[],"trackingID":null,"frame":{"origin":{"x":1685,"y":491},"size":{"x":828,"y":1389}}}]}

if I try to load the custom model with useObjectDetector("default") nothing ever resolves and I am stuck in loading state, so I must use the name as suggested in the docs.

So I am confused:

  1. Does a custom model work with this library?
  2. What is the naming convention needed for custom model references?
@lucksp lucksp changed the title Custom model docs v example confusion Custom model does not work Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant