Giter Club home page Giter Club logo

hms-core / hms-ml-demo Goto Github PK

View Code? Open in Web Editor NEW
348.0 33.0 120.0 234.58 MB

HMS ML Demo provides an example of integrating Huawei ML Kit service into applications. This example demonstrates how to integrate services provided by ML Kit, such as face detection, text recognition, image segmentation, asr, and tts.

Home Page: https://developer.huawei.com/consumer/en/hms/huawei-mlkit?ha_source=hms1

License: Apache License 2.0

Kotlin 3.55% Java 96.41% GLSL 0.04%
hms machine-learning face-recognition face-detection classification huawei image-segmentation ocr document language-detection object-detection-and-tracking id-card-recognition bank-card-recognition text-to-speech audio-file-transcription deep-learning tts-android text-translation asr kotlin-android

hms-ml-demo's Introduction

hms-ml-demo

License

English | 中文

Introduction

This project includes multiple demo apps that showcase the capabilities of the HUAWEI ML Kit.

There are 2 main directories:

  • MLKit-Sample contains a scenario-based demo. To directly download and install Android binaries, scan the QR codes here

  • ApplicationCases contains various application cases

Technical Support

If you are still evaluating HMS Core, obtain the latest information about HMS Core and share your insights with other developers at Reddit.

  • To resolve development issues, please go to Stack Overflow. You can ask questions below the huawei-mobile-services tag, and Huawei R&D experts can solve your problem online on a one-to-one basis.
  • To join the developer discussion, please visit Huawei Developer Forum.

If you have problems using the sample code, submit issues and pull requests to the repository.

hms-ml-demo's People

Contributors

abusuioc avatar chenjingming1 avatar gwwhuawei avatar hms-mlkit avatar huawei-mobile-services-core avatar mike-mei avatar minkiapps avatar tiantian0303 avatar xuejiao-shi avatar xuxiapu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hms-ml-demo's Issues

Is it possible to compress the yuv data in onPreviewFrame()

I found that when set Camera's preview size of 320 * 240,
the speed of face recognition will much faster than
set Camera's preview size of normal phone resolution like 1920 * 1080,
by the way, the preview quality of Camera will be very low.
so, is it possible to compress the yuv data in LensEngine's inner class LensPreviewer's onPreviewFrame() method?
i'm trying to compress the yuv data without changing the parameters of Camera,
in order to Improve the speed of face recognition and keep high quality of Camera's preview

I'm still trying, so if anyone thinks this is a feasible approach, please give me a hint
thanks you~

The liveness Camera View not able make as full screen

MLLivenessDetectView its not able to shown as full screen, its look like already fixed size in the

MLLivenessDetectView() -> setPreviewSite function its already defined the screen height - but I need the MLLivenessDetectView as full screen view. Kindly help on this .,

Thanks in Advance,

Using two offline MLTextAnalyser at same time doesn't work

I have this weird case that as sonn as I try to use more than on offline MLTextAnalyser, they stop scanning any text. If I use one only, it works.

    private val enTextRecognizer : MLTextAnalyzer by lazy {
        MLAnalyzerFactory.getInstance().localTextAnalyzer
    }

    private val cnTextRecognizer : MLTextAnalyzer by lazy {
        val setting = MLLocalTextSetting.Factory()
            .setOCRMode(MLLocalTextSetting.OCR_DETECT_MODE)
            .setLanguage("zh")
            .create()
        MLAnalyzerFactory.getInstance().getLocalTextAnalyzer(setting)
    }
val mlText1 = Tasks.await(enTextRecognizer.asyncAnalyseFrame(MLFrame.fromBitmap(bitmap))) //works
val mlText2 = Tasks.await(cnTextRecognizer.asyncAnalyseFrame(MLFrame.fromBitmap(bitmap))) //doesn't work, and after that enTextRecognizer also stops working

Is this compatible in Google Play Store?

probably i am asking a noob question.
Can the HMS-integrated app, be published in Google Play Store?
(for example, i am using the Face Detection feature from the HMS-Core)

Is it possible to support video recording in future?

Hello, hms-ml-face is a great library.
Is it possible to support video recording function in future?
when i using MediaRecorder to record video
the MediaRecorder will take over Camera From hms-mlsdk's MLLensSelector

Thank you for produced hms-ml-face
it will be better If record function can be supported in future

Photo Translate Example not working

I am trying to run the photo translate example on my Huawei Mate 30 Pro...

  • I setup my own agconnect-services.json and use the correct application id.
  • I enabled ML Kit API on my developer console

Everytime I hit the translate button, I get following exception from textAnalyzer: com.huawei.hms.mlsdk.common.MLException: UrlList is empty, failed to detect cloud text.

Why the VideoView inside LensEnginePreview is always Stretched

Hi, I've noticed that the VideoView is always stretched, I tried to resize it with a custom height, but it doesn't work.

e.g. :

    <com.huawei.mlkit.sample.camera.LensEnginePreview
        android:id="@+id/preview"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:id="@+id/background"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="fitXY" />

        <VideoView
            android:id="@+id/video"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <com.huawei.mlkit.sample.views.overlay.GraphicOverlay
            android:id="@+id/graphic"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </com.huawei.mlkit.sample.camera.LensEnginePreview>

HMS ML Demo - Module text, urlList is null

Hello, when I try to download chinese model for offline translation in module text, I get the following error in logcat:

2020-07-20 23:49:52.142 581-1009/com.mlkit.sample.text E/MLLocalModelManager: queryModelInfo urlList is null!
2020-07-20 23:49:52.155 581-581/com.mlkit.sample.text E/LocalTranslateActivity: downloadModel failed: Failed to obtain model info

and on device toast: "DownloadModel Failed"

Same error appear, when I add ML translate dependencies to my own separate project. Could you please check this issue? Downloading of english model, for example, completed successfully.

音源分离端侧报错

请问使用音源分离端侧接口一直报1007这个错误码,请问导致这个问题的原因有哪些?感谢回复

Removing the background from a video takes a long time to finish

Hi, I hope you're doing well, I'm trying to remove the background from a video, right now I'm following those steps :

1 - Extract all frames from video using FFMPEG

2 - Remove the background from each frame using Huawei ML Image Segmentation and save the bitmap as file to use it later :

    public void analyzer(List<File> files, MLCallBack mlCallBack) {
        for (File file : files) {
            Bitmap frame = ImageUtils.getBitmap(file);
            MLFrame mlFrame = MLFrame.fromBitmap(frame);
            SparseArray<MLImageSegmentation> task = this.analyzer.analyseFrame(mlFrame);
            String noBgFramePath = FileHelper.createImageInNoBackgroundFramesFolder(counter);
            ImageUtils.save(task.get(0).getForeground(), noBgFramePath, Bitmap.CompressFormat.PNG, 60, true);
            mlCallBack.onMLProgress(counter);
            BitmapUtil.recycle(frame);
            FileUtils.delete(file);
            counter++;
        }
        if (counter == files.size())
            mlCallBack.onMLCompleted(true);
    }

3 - Combine all frames (no background) into one video file.

THE ISSUE :

The step 2 (Removing background) takes a long time e.g. video with 26sec takes almost 5min to process, is there any better and faster way to do this, such as using LensEngine or something like that?

IDEA打开引入ApplicationCases后运行报错

我不太了解android这块,但是我自己创建的android工程是可以运行的,不知道您们这示例中的工程模块是聚合还是怎么的,运行后报错
日志报错如下
image

MLCnIcrCaptureResult

身份证识别 成功 回调数据中获取地址为空 MLCnIcrCaptureResult

Getting nullpointer exception : LensEngine LensAnalyzerRunable on using it second time

Hi,

I am using this example to scan the ID card, it is working fine but when i am trying to scan it 2nd time, it is giving me null pointer exception.

Exception thrown from receiver.
java.lang.NullPointerException: tep oivk* ita ehd'odcmhae.m.ld*.omnMAaye*.banitr*(o.uwihsmskcmo.Lrm)* nanl* betrfrne
at com.huawei.hms.mlsdk.common.LensEngine$LensAnalyzerRunable.run(LensEngine.java:734)
at java.lang.Thread.run(Thread.java:929)

plus any reason for getting below logs

forbiddenHiLog.getVenderCountry=meafnaf
forbiddenHiLog openHa = true

Update: we need below code onPause, that will resolve the issue.
this.lensEngine = null;

I still want to know the reason behind forbidden lines.

Thanks in advance for your help.

Black Image When setExact is FALSE

I'm using the following code to get the foreground only from a given bitmap :

    private MLImageSegmentationAnalyzer analyzer;

    public void analyzer(Bitmap src, MLCallBack mlCallBack) {
        MLImageSegmentationSetting setting = new MLImageSegmentationSetting.Factory()
                .setExact(false)
                .setAnalyzerType(MLImageSegmentationSetting.BODY_SEG)
                .setScene(MLImageSegmentationScene.FOREGROUND_ONLY)
                .create();
        
        this.analyzer = MLAnalyzerFactory.getInstance().getImageSegmentationAnalyzer(setting);
        MLFrame mlFrame = new MLFrame.Creator().setBitmap(src).create();
        Task<MLImageSegmentation> task = this.analyzer.asyncAnalyseFrame(mlFrame);
        task.addOnSuccessListener(mlImageSegmentationResults ->
                mlCallBack.onMLCompleted(mlImageSegmentationResults.getForeground()))
                .addOnFailureListener(e ->
                        mlCallBack.onMLFailed());
    }

But the output is always BLACK, when I set .setExact(true), everything works fine, I would like to speed up to background remover process that's why I set False to setExact()

Incomplete README.md

the README.md file doesn't properly explains how to begin with the application and how to run it.
Can someone properly describe the process in the README.md???

ML Body 闪退

2021-11-24 17:38:28.624 11628-11628/com.mlkit.sample.body E/libc: Access denied finding property "ro.vendor.scroll.preobtain.enable"
2021-11-24 17:38:28.653 11628-11738/com.mlkit.sample.body E/linker: library "" ("/apex/com.android.vndk.v30/lib64") needed or dlopened by "/apex/com.android.vndk.v30/lib64/libRS_internal.so" is not accessible for the namespace: [name="rs", ld_library_paths="", default_library_paths="/apex/com.android.vndk.v30/lib64:/vendor/lib64", permitted_paths="/odm/lib64:/vendor/lib64:/system/vendor/lib64:/data"]
2021-11-24 17:38:29.709 11628-11628/com.mlkit.sample.body E/HaLogProvider: forbiddenHiLog.getVenderCountry=UNKNOWN
2021-11-24 17:38:29.709 11628-11628/com.mlkit.sample.body E/HaLogProvider: forbiddenHiLog openHa = false
2021-11-24 17:38:29.723 11628-11785/com.mlkit.sample.body E/CountryCodeBean: getVendorCountry=UNKNOWN
2021-11-24 17:38:29.723 11628-11785/com.mlkit.sample.body E/CountryCodeBean: getSimCountryCode by not enableNetwork, countryCode=cn
2021-11-24 17:38:29.747 11628-11785/com.mlkit.sample.body E/HaLogProvider: forbiddenHiLog.getVenderCountry=UNKNOWN
2021-11-24 17:38:29.747 11628-11785/com.mlkit.sample.body E/HaLogProvider: forbiddenHiLog openHa = false
2021-11-24 17:38:29.752 11628-11783/com.mlkit.sample.body E/HIAI_DDK_MSG: IsLegacyRomItf: Current rom verison not support NPU.
2021-11-24 17:38:29.752 11628-11783/com.mlkit.sample.body E/HIAI_DDK_MSG: IsLegacyRomItf: Current rom verison not support NPU.
2021-11-24 17:38:29.790 11628-11785/com.mlkit.sample.body E/HaLogProvider: forbiddenHiLog.getVenderCountry=UNKNOWN
2021-11-24 17:38:29.790 11628-11785/com.mlkit.sample.body E/HaLogProvider: forbiddenHiLog openHa = false

手机型号:
vivo iqoo pro 5g(V1916A)
android 11
OriginOS1.0

关于Face2D-Sticker的问题

测试过Face2D-Sticker demo后,预览和贴纸是竖屏的,在修改activity为横屏后特征点和贴纸均横向显示,请问如何修改才能达到横向预览并且特征点和贴纸也正确显示?

目前表现:
QQ图片20210112174156

期望结果:
QQ图片20210112174348

灵魂画图 请见谅,
image

Hair Segmentation Not working

Hey team,
I am trying to run hair segmentation but it is not working and is returning null image as output.

private void createImageTransactor(Bitmap bitmap) {

        MLImageSegmentationSetting setting = new MLImageSegmentationSetting
                .Factory()
                // Set the segmentation mode to hair segmentation.
                .setAnalyzerType(MLImageSegmentationSetting.HAIR_SEG)
                .create();

        MLImageSegmentationAnalyzer analyzer = MLAnalyzerFactory.getInstance().getImageSegmentationAnalyzer(setting);

        MLFrame frame = MLFrame.fromBitmap(bitmap);
        Task<MLImageSegmentation> task = analyzer.asyncAnalyseFrame(frame);

        task.addOnSuccessListener(segmentation -> {
            // Detection success.
            foregroundBitmap = segmentation.foreground;
            imageView.setImageBitmap(foregroundBitmap);
        })
                .addOnFailureListener(new OnFailureListener() {
                    @Override
                    public void onFailure(Exception e) {
                        // Detection failure.
                    }
                });
}

Here is the dependencies graph.

// Import the base SDK. implementation 'com.huawei.hms:ml-computer-vision-segmentation:2.2.0.300' // Import the multiclass segmentation model package. implementation 'com.huawei.hms:ml-computer-vision-image-segmentation-multiclass-model:2.2.0.300' // Import the human body segmentation model package. implementation 'com.huawei.hms:ml-computer-vision-image-segmentation-body-model:2.2.0.300' // Import the hair segmentation model package. implementation 'com.huawei.hms:ml-computer-vision-image-segmentation-hair-model:2.2.0.300'

ML-Kit Text: Chinese OCR not working

I am trying to use the offline Chinese text recognition on my Google Pixel 2 XL, it is not working.
I have HMS Core installed on my device. (Version: 5.0.1.313)

This is the code how I initialise MLTextAnalyser:

private val hmsTextRecognizer : MLTextAnalyzer by lazy {
     val setting = MLLocalTextSetting.Factory()
         .setOCRMode(MLLocalTextSetting.OCR_DETECT_MODE)
         .setLanguage("zh")
         .create()
     MLAnalyzerFactory.getInstance().getLocalTextAnalyzer(setting)
}

The TextAnalyser doesn't recognise any text.
I see following error:

E/CountryCodeBean: getVendorCountry=UNKNOWN
E/CountryCodeBean: getSimCountryCode by not enableNetwork, countryCode=at
E/CountryCodeBean: getVendorCountry=UNKNOWN
E/CountryCodeBean: getSimCountryCode by not enableNetwork, countryCode=at
E/HaLogProvider: forbiddenHiLog.getVenderCountry=UNKNOWN
E/HaLogProvider: forbiddenHiLog openHa = false
E/FocusShootOCREngine: ocr load model failed
E/HaLogProvider: forbiddenHiLog.getVenderCountry=UNKNOWN
E/HaLogProvider: forbiddenHiLog openHa = false

On my Huawei Mate 30 Pro it works.

Proguard rules for MLTextAnalyzer

If I turn on obfuscation, which is critically required since all my apps are obfuscated, the text analyser stops recognising any text...

Could you provide Proguard rules?

Custom model - model conversion from TensorFlow lite

Can you provide a TensorFlow Lite model and the steps to convert it and make it working with the project?

I tried to convert the model with the HMS Toolkit but the model produced generated
an exception in the MLExecutor getInstance.

Hello I am using ML kit Document skew correction and it is crashing on android 9 only

When the app gets on this line analyzer.asyncDocumentSkewDetect(frame)
the app crashes with the following error, also everything working fine on android 8, 10, 11 , 12

E/cv::error(): OpenCV(4.5.2) Error: Assertion failed (total() == 0 || data != NULL) in Mat, file /opt/huawei/algo_compiling/opencv/opencv-4.5.2/modules/core/src/matrix.cpp, line 428
E/libc++abi: terminating with uncaught exception of type cv::Exception: OpenCV(4.5.2) /opt/huawei/algo_compiling/opencv/opencv-4.5.2/modules/core/src/matrix.cpp:428: error: (-215:Assertion failed) total() == 0 || data != NULL in function 'Mat'
A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 20200 (doc_scanner_app), pid 20200 (doc_scanner_app)

TTS not working in HomeReader example

Hi, I am trying to test the homework reader example, the text recognition part works, but the read function does not work

This is what I get:

E/ML_TTS_SynthesisEngineOnline: Speech synthesis request failed!
E/ML_TTS_SpeechSynthesisController: Receive engine error taskId[1595757576654554] errorCode[105] errorMsg[network no response]

I enabled the ML-Kit API in Huawei Developer Console, and also I am connected to WIFI.
I am running on Huawei Mate 30 Pro...

App crash when updating to 3.0.0.301

    implementation 'com.huawei.hms:ml-computer-vision-segmentation:3.0.0.301'
    implementation 'com.huawei.hms:ml-computer-vision-image-segmentation-multiclass-model:3.0.0.301'
    implementation 'com.huawei.hms:ml-computer-vision-image-segmentation-body-model:3.0.0.301'
public class ImageSegmentation {

    private MLImageSegmentationAnalyzer analyzer;

    public void analyzer(Bitmap src, MLCallBack mlCallBack) {
        MLImageSegmentationSetting setting = new MLImageSegmentationSetting.Factory()
                .setExact(true)
                .setAnalyzerType(MLImageSegmentationSetting.BODY_SEG)
                .setScene(MLImageSegmentationScene.FOREGROUND_ONLY)
                .create();
        this.analyzer = MLAnalyzerFactory.getInstance().getImageSegmentationAnalyzer(setting);
        MLFrame mlFrame = new MLFrame.Creator().setBitmap(src).create();
        Task<MLImageSegmentation> task = this.analyzer.asyncAnalyseFrame(mlFrame);
        task.addOnSuccessListener(imageSegmentationResult -> {
            if (imageSegmentationResult != null) mlCallBack.onMLCompleted(imageSegmentationResult);
            else mlCallBack.onMLFailed();
        }).addOnFailureListener(e -> mlCallBack.onMLFailed());
    }

}
2021-08-04 00:35:50.103 32383-32383/maa.abc.background_changer E/ActivityThread: Failed to find provider info for com.huawei.hms
2021-08-04 00:35:50.109 32383-32383/maa.abc.background_changer E/AbstractInitializer: huawei_module_mlkit_imgseg -> No need to switch because the context of the dynamic module is null or the context of full sdk
2021-08-04 00:35:50.109 32383-32383/maa.abc.background_changer E/AbstractInitializer: huawei_module_mlkit_imgseg -> The context of the dynamic module belongs to LOCAL
2021-08-04 00:35:50.156 32383-32383/maa.abc.background_changer E/HIAI_DDK_MSG: /AiDllParser.cpp Load(45)::"dlopen load lib failed,lib[/system/lib64/libhiai_foundation.huawei.so],errmsg [dlopen failed: can't read file "/data/app/~~tmU2wHTAY38LvsdjeofDpA==/maa.abc.background_changer-QDVrIWUG8BkHCusrq3t_HQ==/lib/arm64": Is a directory]"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.