Setting up MLKIT Firebase on Android
Google launched MLKIT in it Google I/O 2018, this is one big step for any of the tech giant to make the trained model available for developers. Google went one step ahead and made it available on a mobile device that run locally and most f the without an internet connection. Although Amazon Web Services ( AWS ) also provide similar services through it Machine Leaning, Rekognition and other service but all of them require an internet connection and setting it up to work in real-time is a big pain.
There are few important points that Google’s ML took care of:
- Platform Independent ( Android / IOS )
The above points will give MLKIT worldwide acceptance. For a developer its a nightmare to train model, collect data sample and then make those trained available for use. After Tensors flow, this is the next big step of the company toward contributing to the community.
So what all MLKIT offers:
For starting there are few ready-made models available for beginners:
- Text recognition
- Face detection
- Barcode scanning
- Image labeling
- Landmark recognition
However, you can also use your own Tensor Flows Lite models for taking care of custom scenarios.
In this blog, we will set up a sample app and configure it to use MLKIT and setup Face tracking. The Facetracking Model can detect the following things:
- Happiness ( Range 0 – 1 )
- Left & Right Eye closing ( Range 0 – 1 )
So in order to start, clone the following Repo: https://github.com/ankitjamuar/android-firebase-mlkit.git , everything is working on it, you might have to setup google-services.json file.
Now open the project in Android studio, and connect your mobile and install the APK . The first screen will have a start button, press the start button and it will open an activity with camera preview. if you put a human face in front of camera you will be able to see MLKIT in action., it will show a bounding box around the face and values of Happiness, left & right eye open status.
How to download google-services.json file.
Go to Firebase console, create a project and select Android Project on the next page, next page will ask for package name and other optional detail. fill those detail and in next step, it will ask to download the google-services.json file. Put the file in “app” directory and sync it.