当前位置:网站首页>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);
边栏推荐
- 金融市场,资产管理与投资基金
- 攻防世界 MISC 进阶区 hong
- Unity vscode emmylua configuration error resolution
- S32 Design Studio for ARM 2.2 快速入门
- Attack and Defense World MISC Advanced Area Erik baleog and Olaf
- 攻防世界 MISC 进阶区 hit-the-core
- 攻防世界 misc 进阶区 2017_Dating_in_Singapore
- Redis getting started complete tutorial: publish and subscribe
- SPH中的粒子初始排列问题(两张图解决)
- 【ODX Studio编辑PDX】-0.3-如何删除/修改Variant变体中继承的(Inherited)元素
猜你喜欢
VIM editor knowledge summary
Redis introduction complete tutorial: Collection details
S32 Design Studio for ARM 2.2 快速入门
vim编辑器知识总结
Talk about Middleware
页面关闭前,如何发送一个可靠请求
Attack and defense world misc advanced zone 2017_ Dating_ in_ Singapore
MySQL Architecture - user rights and management
Erik baleog and Olaf, advanced area of misc in the attack and defense world
Redis入门完整教程:HyperLogLog
随机推荐
攻防世界 MISC 高手进阶区 001 normal_png
Redis入门完整教程:HyperLogLog
Principle of lazy loading of pictures
MySQL Architecture - user rights and management
【二叉树】节点与其祖先之间的最大差值
A complete tutorial for getting started with redis: hyperloglog
The solution to the lack of pcntl extension under MAMP, fatal error: call to undefined function pcntl_ signal()
Pagoda 7.9.2 pagoda control panel bypasses mobile phone binding authentication bypasses official authentication
Hit the core in the advanced area of misc in the attack and defense world
[try to hack] wide byte injection
Taobao commodity review API interface (item_review get Taobao commodity review API interface), tmall commodity review API interface
SHP data making 3dfiles white film
【室友用一局王者荣耀的时间学会了用BI报表数据处理】
9 - class
Attack and defense world misc advanced zone 2017_ Dating_ in_ Singapore
剑指 Offer 68 - I. 二叉搜索树的最近公共祖先
[OpenGL] note 29 anti aliasing (MSAA)
Editplus-- usage -- shortcut key / configuration / background color / font size
攻防世界 MISC 进阶区 can_has_stdio?
Duplicate ADMAS part name