Beginner : Building Custom model using Huawei ML kit Custom Model

Search This thread


Senior Member
Nov 30, 2020


Are you new to machine learning?

If yes. Then let’s start from the scratch.

What is machine learning?

Definition: “
Field of study that gives computer capability to learn without being explicitly programmed.”

In general: Machine learning is an Application of the Artificial intelligence (AI) it gives devices the ability to learn from their experience improve their self-learning without doing any coding. For example if you search something related Ads will be shown on the screen.

Machine Learning is a subset of Artificial Intelligence. Machine Learning is the study of making machines more human-like in their behavior and decisions by giving them the ability to learn and develop their own programs. This is done with minimum human intervention, that is, no explicit programming. The learning process is automated and improved based on the experiences of the machines throughout the process. Good quality data is fed to the machines, and different algorithms are used to build ML models to train the machines on this data. The choice of algorithm depends on the type of data at hand, and the type of activity that needs to be automated.

Do you have question like what is the difference between machine learning and traditional programming?


Traditional programming

We would feed the input data and well written and tested code into machine to generate output.

Machine Learning

We feed the Input data along with the output is fed into the machine during the learning phase, and it works out a program for itself.

Steps of machine learning

1. Gathering Data

2. Preparing that data

3. Choosing a model

4. Training

5. Evaluation

6. Hyper parameter Tuning

7. Prediction

How does Machine Learning work?


The three major building blocks of a Machine Learning system are the model, the parameters, and the learner.

  • Model is the system which makes predictions.
  • The parameters are the factors which are considered by the model to make predictions.
  • The learner makes the adjustments in the parameters and the model to align the predictions with the actual results.
Now let’s build on the water example from the above and learn how machine learning works. A machine learning model here has to predict whether water is useful to drink or not. The parameters selected are as follows

  • Dissolved oxygen
  • pH
  • Temperature
  • Decayed organic materials
  • Pesticides
  • Toxic and hazardous substances
  • Oils, grease, and other chemicals
  • Detergents
Learning from the training set.

This involves taking a sample data set of several place water for which the parameters are specified. Now, we have to define the description of each classification that is useful to drink water, in terms of the value of parameters for each type. The model can use the description to decide if a new sample of water is useful to drink or not.

You can represent the values of the parameters, ‘pH’ ,‘Temperature’ , ‘Dissolved oxygen’ etc, as ‘x’ , ‘y’ and ‘z’ etc. Then (x, y, z) defines the parameters of each drink in the training data. This set of data is called a training set. These values, when plotted on a graph, present a hypothesis in the form of a line, a rectangle, or a polynomial that fits best to the desired results.

Now we have learnt what machine learning is and how it works, now let’s understand about Huawei ML kit.

Huawei ML kit

HUAWEI ML Kit allows your apps to easily leverage Huawei's long-term proven expertise in machine learning to support diverse artificial intelligence (AI) applications throughout a wide range of industries.

Huawei has already provided some built in feature in SDK which are as follows.

  • Text related service.
    • Text recognition
    • Document recognition
    • Id card recognition
    • Bank card recognition
    • General card recognition
    • Form Recognition
  • Language/Voice related services.
    • Translation
    • Language detection
    • Text to speech
  • Image related services.
    • Image classification
    • Object detection and Tracking
    • Landmark recognition
    • Product visual search
    • Image super resolution
    • Document skew correction
    • Text image super resolution
    • Scene detection
  • Face/Body related services.
    • Face detection
    • Skeleton detection
    • Liveness detection
    • Hand gesture recognition
    • Face verification
  • Natural language processing services.
    • Text embedding
  • Custom model.
    • AI create
    • Model deployment and Inference
    • Pre-trained model
In this series of article we learn about Huawei Custom model. As an on-device inference framework of the custom model, the on-device inference framework MindSpore Lite provided by ML Kit facilitates integration and development and can be running on devices. By introducing this inference framework, you can define your own model and implement model inference at the minimum cost.

Advantages of MindSpore Lite

  • It provides simple and complete APIs for you to integrate the inference framework of an on-device custom model.
  • Customize model in simple and quickest with excellent experience with Machine learning.
  • It is compatible with all mainstream model inference platforms or frameworks, such as MindSpore Lite, TensorFlow Lite, Caffe, and Onnx in the market. Different models can be converted into the .ms format without any loss, and then run perfectly through the on-device inference framework.
  • Custom models occupy small storage space and can be quantized and compressed. Models can be quickly deployed and executed. In addition, models can be hosted on the cloud and downloaded as required, reducing the APK size.
Steps to be followed to Implement Custom model

Step 1:
Install HMS Toolkit from Android Studio Marketplace.

Step 2: Transfer learning by using AI Create.

Step 3: Model training

Step 4: Model verification

Step 5: Upload model to AGC

Step 6: Load the remote model

Step 7: Perform inference using model inference engine

Let us start one by one.

Step 1: Install HMS Toolkit from Android Studio Marketplace. After the installation, restart Android Studio.

· Choose File > Setting > Plugins





Coming soon in upcoming article.

Tips and Tricks

  • Make sure you are already registered as Huawei Developer.
  • Learn basic of machine learning.
  • Install HMS tool in android studio

In this article, we have learnt what exactly machine learning is and how it works. And difference between traditional programming and machine learning. Steps required to build custom model and also how to install HMS tool in android studio. In upcoming article I’ll continue the remaining steps in custom model of machine learning.


ML Kit Official document

Checkout in forum
Last edited:
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone