当前位置:网站首页>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 進階區 Erik-Baleog-and-Olaf
- Photoshop batch adds different numbers to different pictures
- Attack and defense world misc advanced area Hong
- Excel 快捷键-随时补充
- Qt个人学习总结
- Taobao commodity review API interface (item_review get Taobao commodity review API interface), tmall commodity review API interface
- Redis démarrer le tutoriel complet: Pipeline
- 剑指Offer 68 - II. 二叉树的最近公共祖先
- Gnawing down the big bone - sorting (II)
- A complete tutorial for getting started with redis: redis usage scenarios
猜你喜欢
Redis入门完整教程:事务与Lua
Co create a collaborative ecosystem of software and hardware: the "Joint submission" of graphcore IPU and Baidu PaddlePaddle appeared in mlperf
Attack and defense world misc advanced area Hong
Talk about Middleware
Redis introduction complete tutorial: List explanation
Attack and Defense World MISC Advanced Area Erik baleog and Olaf
攻防世界 misc 进阶区 2017_Dating_in_Singapore
Breakpoint debugging under vs2019 c release
One of the commonly used technical indicators, reading boll Bollinger line indicators
Redis入门完整教程:Pipeline
随机推荐
Tweenmax emoticon button JS special effect
云服务器设置ssh密钥登录
页面关闭前,如何发送一个可靠请求
【ODX Studio编辑PDX】-0.3-如何删除/修改Variant变体中继承的(Inherited)元素
Attack and defense world misc advanced area can_ has_ stdio?
Redis入门完整教程:集合详解
Unity Xiuxian mobile game | Lua dynamic sliding function (specific implementation of three source codes)
图片懒加载的原理
Redis入门完整教程:慢查询分析
Redis introduction complete tutorial: Collection details
微信小程序显示样式知识点总结
Redis getting started complete tutorial: Geo
【二叉树】节点与其祖先之间的最大差值
On-off and on-off of quality system construction
C语言快速解决反转链表
MySQL Architecture - logical architecture
[odx Studio Edit pdx] - 0.2 - Comment comparer deux fichiers pdx / odx
Redis入门完整教程:有序集合详解
Gnawing down the big bone - sorting (II)
The solution to the lack of pcntl extension under MAMP, fatal error: call to undefined function pcntl_ signal()