Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using two offline MLTextAnalyser at same time doesn't work #27

Open
minkiapps opened this issue Aug 21, 2020 · 8 comments
Open

Using two offline MLTextAnalyser at same time doesn't work #27

minkiapps opened this issue Aug 21, 2020 · 8 comments
Assignees

Comments

@minkiapps
Copy link
Contributor

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
@Mike-mei
Copy link
Contributor

Please check whether you have loaded Chinese model or not.

implementation ‘com.huawei.hms : ml-computer-vision-ocr-cn-model : 2.0.2.200.013’

@minkiapps
Copy link
Contributor Author

I have

    implementation 'com.huawei.hms:ml-computer-vision-ocr-latin-model:2.0.1.300'
    implementation 'com.huawei.hms:ml-computer-vision-ocr-cn-model:2.0.1.300'
    implementation 'com.huawei.hms:ml-computer-vision-ocr:2.0.1.300'

@Mike-mei
Copy link
Contributor

Mike-mei commented Sep 1, 2020

We plan to release new 2.0.3.300 version on 10th September, and this issue will be fixed

@minkiapps
Copy link
Contributor Author

please tell me as soon as they are released

@minkiapps
Copy link
Contributor Author

minkiapps commented Sep 27, 2020

I updated the version to
implementation 'com.huawei.hms:ml-computer-translate:2.0.3.300'

code is opensource, find it here
now I face the issue again with translation model download failed, here the log:

E/MLInitializerProvider: MLInitializerProvider Done
E/ML_CountryCodeHelper: getVendorCountry=eu
E/ML_CountryCodeHelper: getVendorCountry equals eu or la ,not reliable
E/ML_CountryCodeHelper: getSimCountryCode by not enableNetwork, countryCode=it
E/.livetranslato: Invalid ID 0x00000000.
E/CountryCodeBean: getVendorCountry=eu
E/CountryCodeBean: getVendorCountry equals eu or la ,not reliable
E/CountryCodeBean: getSimCountryCode by not enableNetwork, countryCode=it
E/ML_TTS_SpeakerProvider: Response error! errcode=[7010] retMsg=[Token is invalid or expired]
E/ML_TTS_SpeakerProvider: Use default List; Voice list parse error.[{"retCode":"7010","retMsg":"Token is invalid or expired"}]
E/AbstractInitializer: huawei_module_mlkit_translate -> isForce = false, isCreatorClassRemote = true, isLocalExisted = true
E/AbstractInitializer: huawei_module_mlkit_translate -> The context of the dynamic module belongs to REMOTE
E/HaLogProvider: forbiddenHiLog.getVenderCountry=UNKNOWN
E/HaLogProvider: forbiddenHiLog openHa = true
E/HaLogProvider: forbiddenHiLog.getVenderCountry=UNKNOWN
E/HaLogProvider: forbiddenHiLog openHa = true
E/HaLogProvider: initlizeHaSdk APK mode,BUILD_MODE=APK
E/HaLogProvider: GrsApi.synGetGrsUrl=https://metrics2.data.hicloud.com:6447,BuildConfig.HIA_MODE=com.huawei.cloud.mlkithianalytics
E/CountryCodeBean: getVendorCountry=eu
E/CountryCodeBean: getVendorCountry equals eu or la ,not reliable
E/CountryCodeBean: getSimCountryCode by not enableNetwork, countryCode=it
E/HaLogProvider: forbiddenHiLog.getVenderCountry=UNKNOWN
E/HaLogProvider: forbiddenHiLog openHa = true
E/HaLogProvider: forbiddenHiLog.getVenderCountry=UNKNOWN
E/HaLogProvider: forbiddenHiLog openHa = true
E/AbstractInitializer: huawei_module_mlkit_translate -> Something wrong, need to switch context, current is REMOTE
E/AbstractInitializer: huawei_module_mlkit_translate -> Switch the context of the dynamic module to LOCAL
E/HaLogProvider: forbiddenHiLog.getVenderCountry=UNKNOWN
E/HaLogProvider: forbiddenHiLog openHa = true
E/HaLogProvider: forbiddenHiLog.getVenderCountry=UNKNOWN
E/HaLogProvider: forbiddenHiLog openHa = true
E/HaLogProvider: initlizeHaSdk APK mode,BUILD_MODE=APK
E/HaLogProvider: GrsApi.synGetGrsUrl=https://metrics2.data.hicloud.com:6447,BuildConfig.HIA_MODE=com.huawei.cloud.mlkithianalytics
E/CountryCodeBean: getVendorCountry=eu
E/CountryCodeBean: getVendorCountry equals eu or la ,not reliable
E/CountryCodeBean: getSimCountryCode by not enableNetwork, countryCode=it
E/HaLogProvider: forbiddenHiLog.getVenderCountry=UNKNOWN
E/HaLogProvider: forbiddenHiLog openHa = true
E/HaLogProvider: forbiddenHiLog.getVenderCountry=UNKNOWN
E/HaLogProvider: forbiddenHiLog openHa = true
E/AbstractInitializer: huawei_module_mlkit_translate -> Something wrong, need to switch context, current is LOCAL
E/CountryCodeBean: getVendorCountry=eu
E/CountryCodeBean: getVendorCountry equals eu or la ,not reliable
E/CountryCodeBean: getSimCountryCode by not enableNetwork, countryCode=it
E/MainViewModel: Failed to download language models
    java.util.concurrent.ExecutionException: com.huawei.hms.mlsdk.common.MLException: Download model failed
        at com.huawei.hmf.tasks.a.j.a(Unknown Source:17)
        at com.huawei.hmf.tasks.Tasks.await(Unknown Source:33)
        at com.minkiapps.livetranslator.MainViewModel.downloadModel(MainViewModel.kt:60)
        at com.minkiapps.livetranslator.MainViewModel.access$downloadModel(MainViewModel.kt:15)
        at com.minkiapps.livetranslator.MainViewModel$initModels$2$chinesModelAvailableTask$1.invokeSuspend(MainViewModel.kt:41)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
     Caused by: com.huawei.hms.mlsdk.common.MLException: Download model failed
        at com.huawei.hms.mlsdk.model.download.p.s.a(RemoteDownloadManager.java:162)
        at com.huawei.hms.mlsdk.model.download.p.s.a(RemoteDownloadManager.java:33)
        at com.huawei.hms.mlsdk.model.download.p.u.a(TranslateModelManagerDelegate.java:31)
        at com.huawei.hms.mlsdk.model.download.p.e.a(ModelDownloadManagerDelegate.java:13)
        at com.huawei.hms.mlsdk.model.download.MLLocalModelManager$b.call(MLLocalModelManager.java:3)
        at com.huawei.hmf.tasks.a.j$1.run(Unknown Source:4)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:929)

@Mike-mei
Copy link
Contributor

Hello @minkiapps
As is shown in the log, "Token is invalid or expired", the cause of "model download failed" maybe is Token is empty or invalid.

E/ML_TTS_SpeakerProvider: Response error! errcode=[7010] retMsg=[Token is invalid or expired]

We find your code is that:

MLApplication.getInstance().apiKey = config.getString("client/api_key")

The agc file has been set right?
please see the wiki

@minkiapps
Copy link
Contributor Author

minkiapps commented Oct 18, 2020

Hey, I found out my app id in json file had a space in the middle, sorry on my side.

Nevertheless, my original error still persists after updating the dependency.. see first my first post.
checkout my branch, as soon as I try to use the second ocr model, it stops recognising anything..

@RXlung
Copy link

RXlung commented Aug 12, 2024

HaLogProvider和CountryCodeBean输出的极快而且量极大,如何控制不要输出这个?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants