当前位置:网站首页>HMS core machine learning service
HMS core machine learning service
2022-07-04 23:03:00 【Just_ Paranoid】
Machine learning services (ML Kit) Provide machine learning kits , Develop various applications for developers using machine learning capabilities , Provide quality experience . Thanks to Huawei's long-term technology accumulation ,ML Kit Easy to use for developers 、 Diverse services 、 Technology leading machine learning capabilities , Help developers develop all kinds of products faster and better AI application .
- Text module : Text recognition 、 Document recognition 、 ID card identification 、 Bank card identification 、 Universal card identification 、 Text translation 、 Language detection 、 Real time speech recognition 、 speech synthesis 、 Offline speech synthesis 、 Audio file transcribing 、 Voice recognition 、 Text embedding 、 Real time voice transcribe
- Visual modules : Image segmentation 、 Object detection and tracking 、 Image classification 、 Landmark recognition 、 Image super-resolution 、 Text image super resolution 、 Scene recognition 、 Form identification 、 Document correction
- Body block : Face detection 、3D Face detection 、 Human bone test 、 In vivo detection 、 Hand key point recognition 、 Gesture recognition 、 Face to face comparison
- Demo of custom model Demo
guide :
https://developer.huawei.com/consumer/cn/doc/development/hiai-Guides/service-introduction-0000001050040017
Service dependency list
https://developer.huawei.com/consumer/cn/doc/development/hiai-Guides/overview-sdk-0000001051070278
Text recognition
//1. Create a text parser MLTextAnalyzer Used to identify words in pictures , You can MLLocalTextSetting Set the recognized language , Without setting language, only Latin characters can be recognized by default .
// Mode one : Configure the end-to-end text analyzer with default parameters , Only Latin characters can be recognized .
MLTextAnalyzer analyzer = MLAnalyzerFactory.getInstance().getLocalTextAnalyzer();
// Mode two : Use custom parameters MLLocalTextSetting Configure the end-to-side text analyzer .
MLLocalTextSetting setting = new MLLocalTextSetting.Factory()
.setOCRMode(MLLocalTextSetting.OCR_DETECT_MODE)
// Set the recognition language .
.setLanguage("zh")
.create();
MLTextAnalyzer analyzer = MLAnalyzerFactory.getInstance().getLocalTextAnalyzer(setting);
//2. adopt android.graphics.Bitmap establish MLFrame, Supported image formats include :jpg/jpeg/png/bmp, It is recommended to input the image aspect ratio range :1:2 To 2:1.
// adopt bitmap establish MLFrame,bitmap For input Bitmap Format picture data .
MLFrame frame = MLFrame.fromBitmap(bitmap);
//3. The generated MLFrame Object passed to asyncAnalyseFrame Methods for character recognition .
Task<MLText> task = analyzer.asyncAnalyseFrame(frame);
task.addOnSuccessListener(new OnSuccessListener<MLText>() {
@Override
public void onSuccess(MLText text) {
// Identify successful processing .
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
// Identification failure handling .
}
});
// The asynchronous invocation method is used in the sample code , Local text recognition also supports analyseFrame Synchronous call mode , Identify results with “MLText.Block” Array
Context context = getApplicationContext();
MLTextAnalyzer analyzer = new MLTextAnalyzer.Factory(context).setLocalOCRMode(MLLocalTextSetting.OCR_DETECT_MODE).setLanguage("zh").create();
SparseArray<MLText.Block> blocks = analyzer.analyseFrame(frame);
//4. Identification complete , Stop the analyzer , Release identification resources .
try {
if (analyzer != null) {
analyzer.stop();
}
} catch (IOException e) {
// exception handling .
}
Still image detection
//1. Create a picture classification analyzer . You can customize classes by image classification MLLocalClassificationAnalyzerSetting Create Analyzer .
// Mode one : End side identification uses user-defined parameter configuration .
MLLocalClassificationAnalyzerSetting setting =
new MLLocalClassificationAnalyzerSetting.Factory()
.setMinAcceptablePossibility(0.8f)
.create();
MLImageClassificationAnalyzer analyzer = MLAnalyzerFactory.getInstance().getLocalImageClassificationAnalyzer(setting);
// Mode two : End side identification uses the default parameter configuration .
MLImageClassificationAnalyzer analyzer = MLAnalyzerFactory.getInstance().getLocalImageClassificationAnalyzer();
//2. adopt android.graphics.Bitmap establish MLFrame, Supported image formats include :jpg/jpeg/png/bmp, It is suggested that the size of the picture should not be less than 112*112 Pixels .
// adopt bitmap establish MLFrame,bitmap For input Bitmap Format picture data .
MLFrame frame = MLFrame.fromBitmap(bitmap);
//3. call asyncAnalyseFrame Method for image classification ( Error code information can be found in : Machine learning service error code ).
Task<List<MLImageClassification>> task = analyzer.asyncAnalyseFrame(frame);
task.addOnSuccessListener(new OnSuccessListener<List<MLImageClassification>>() {
@Override
public void onSuccess(List<MLImageClassification> classifications) {
// Recognition success .
// Traverse the returned list MLImageClassification, Get classification name and other information .
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
// Recognition failed .
// Recognition failure.
try {
MLException mlException = (MLException)e;
// Get error code , Developers can handle error codes , According to the error code for differentiated page prompt .
int errorCode = mlException.getErrCode();
// Get error information , Developers can combine error codes , Fast location problem .
String errorMessage = mlException.getMessage();
} catch (Exception error) {
// Conversion error handling .
}
}
});
//4. Identification complete , Stop the analyzer , Release detection resources .
try {
if (analyzer != null) {
analyzer.stop();
}
} catch (IOException e) {
// exception handling .
}
// The asynchronous call method is used in the above example code , Image classification also supports the use of synchronous calls analyseFrame Function to get the detection result :
SparseArray<MLImageClassification> classifications = analyzer.analyseFrame(frame);
边栏推荐
- Attack and defense world misc advanced zone 2017_ Dating_ in_ Singapore
- D3.js+Three. JS data visualization 3D Earth JS special effect
- Redis入门完整教程:事务与Lua
- 云服务器设置ssh密钥登录
- 共创软硬件协同生态:Graphcore IPU与百度飞桨的“联合提交”亮相MLPerf
- Redis入门完整教程:GEO
- EditPlus--用法--快捷键/配置/背景色/字体大小
- 攻防世界 MISC 进阶区 hong
- How to choose a securities company? Is it safe to open an account on your mobile phone
- How to send a reliable request before closing the page
猜你喜欢
How to send a reliable request before closing the page
Complete tutorial for getting started with redis: bitmaps
Redis getting started complete tutorial: hash description
页面关闭前,如何发送一个可靠请求
【室友用一局王者荣耀的时间学会了用BI报表数据处理】
Redis入門完整教程:Pipeline
PS style JS webpage graffiti board plug-in
Analysis of the self increasing and self decreasing of C language function parameters
A complete tutorial for getting started with redis: redis shell
Qt个人学习总结
随机推荐
Analog rocker controlled steering gear
Persistence mechanism of redis
攻防世界 MISC 进阶区 hit-the-core
【剑指Offer】6-10题
Explanation of bitwise operators
ETCD数据库源码分析——处理Entry记录简要流程
A complete tutorial for getting started with redis: understanding and using APIs
Qt加法计算器(简单案例)
Redis入门完整教程:有序集合详解
剑指 Offer 67. 把字符串转换成整数
Principle of lazy loading of pictures
Summary of wechat applet display style knowledge points
Redis入门完整教程:集合详解
A complete tutorial for getting started with redis: Pipeline
Attack and Defense World MISC Advanced Area Erik baleog and Olaf
C语言快速解决反转链表
Google Earth engine (GEE) - tasks upgrade enables run all to download all images in task types with one click
Redis introduction complete tutorial: slow query analysis
P2181 对角线和P1030 [NOIP2001 普及组] 求先序排列
A complete tutorial for getting started with redis: redis shell