invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.64k stars 2.21k forks source link

ML methods not found #6249

Closed wilav-dev closed 2 years ago

wilav-dev commented 2 years ago

Issue

I'm trying to use ml barcodeDetectorProcessImage, faceDetectorProcessImage and cloudDocumentTextRecognizerProcessImage. I was not able to find examples in the documentation. I'm getting the following error

[TypeError: (0, _ml.default)().cloudDocumentTextRecognizerProcessImage is not a function. (In '(0, _ml.default)().cloudDocumentTextRecognizerProcessImage(imagePath)', '(0, _ml.default)().cloudDocumentTextRecognizerProcessImage' is undefined)]

I enabled 3 models in firebase.json and Vision API in Google Cloud.


package.json:

"@react-native-firebase/analytics": "^14.9.1",
"@react-native-firebase/app": "^14.9.1",
"@react-native-firebase/auth": "^14.9.1",
"@react-native-firebase/crashlytics": "^14.9.1",
"@react-native-firebase/dynamic-links": "^14.9.1",
"@react-native-firebase/messaging": "^14.9.1",
"@react-native-firebase/ml": "^14.9.1",

firebase.json for react-native-firebase v6:

{
    "react-native": {
        "crashlytics_debug_enabled": false,
        "ml_vision_barcode_model": true,
        "ml_vision_face_model": true,
        "ml_vision_ocr_model": true
    }
}
mikehardy commented 2 years ago

Indeed, all of the on-device ML APIs were removed from firebase quite some time ago, leaving us with nothing except custom model downloading in the native SDKs, and those are not exposed at the moment, for lack of interest in general:

https://rnfirebase.io/ml/usage#usage

Current no public APIs

The last version that supported them was version 11.5.0 here: https://github.com/invertase/react-native-firebase/blob/main/CHANGELOG.md#breaking-changes-2 (which is not recommended, but just indicates when they were removed - I suppose you could try it)

The on-device ML features in general have moved to MLKit native SDKs from google. We (Invertase) had/have some plans to extract the MLKit APIs to their own package similar to what we did with the Admob APIs removed from firebase, which we now maintain as https://github.com/invertase/react-native-google-mobile-ads - but we have not done that as of yet, again mostly for lack of apparent interest (with apologies to those that are interested - we are aware there some)

In the meantime, perhaps this would work? https://github.com/agoldis/react-native-mlkit-ocr

wilav-dev commented 2 years ago

I found this library which has many features https://github.com/a7med-mahmoud/react-native-ml-kit