firebase / quickstart-android

Firebase Quickstart Samples for Android
https://firebase.google.com
Apache License 2.0
8.87k stars 7.33k forks source link

Waiting for the text recognition model to be downloaded. Please wait #784

Closed ayalma closed 5 years ago

ayalma commented 5 years ago

problem

Text detection failed.com.google.firebase.ml.common.FirebaseMLException: Waiting for the text recognition model to be downloaded. Please wait.

Steps to reproduce:

I just cloned your repo

Observed Results:

2019-01-13 15:45:53.429 32741-572/com.google.firebase.samples.apps.mlkit I/Vision: Loading library libocr.so 2019-01-13 15:45:53.429 32741-572/com.google.firebase.samples.apps.mlkit I/Vision: libocr.so library load status: false 2019-01-13 15:45:53.429 32741-572/com.google.firebase.samples.apps.mlkit W/TextNativeHandle: Native handle not yet available. Reverting to no-op handle. 2019-01-13 15:45:53.430 32741-572/com.google.firebase.samples.apps.mlkit W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.dynamite.text not found. 2019-01-13 15:45:53.435 32741-572/com.google.firebase.samples.apps.mlkit I/DynamiteModule: Considering local module com.google.android.gms.vision.dynamite.text:0 and remote module com.google.android.gms.vision.dynamite.text:0 2019-01-13 15:45:53.436 32741-572/com.google.firebase.samples.apps.mlkit W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.dynamite not found. 2019-01-13 15:45:53.440 32741-572/com.google.firebase.samples.apps.mlkit I/DynamiteModule: Considering local module com.google.android.gms.vision.dynamite:0 and remote module com.google.android.gms.vision.dynamite:1800 2019-01-13 15:45:53.440 32741-572/com.google.firebase.samples.apps.mlkit I/DynamiteModule: Selected remote version of com.google.android.gms.vision.dynamite, version >= 1800 2019-01-13 15:45:53.444 32741-572/com.google.firebase.samples.apps.mlkit I/Vision: Loading library libocr.so 2019-01-13 15:45:53.444 32741-572/com.google.firebase.samples.apps.mlkit I/Vision: libocr.so library load status: false 2019-01-13 15:45:53.448 32741-32741/com.google.firebase.samples.apps.mlkit W/TextRecProc: Text detection failed.com.google.firebase.ml.common.FirebaseMLException: Waiting for the text recognition model to be downloaded. Please wait.

samtstern commented 5 years ago

@ayalma does the download ever complete or are you stuck waiting for the model indefinitely? Also is this specific to a certain device or network?

ayalma commented 5 years ago

Yes , it's stuck in waiting. I tested in my friend Lg device and problem exist. And for network i tested it with wifi and mobile date and even i used vpn for that and still this problem exist .

carlosgub commented 5 years ago

This happens to me one time, I only w8 like 10 minutes because the device is downloading the model, and later work without problem

the-dagger commented 5 years ago

@samtstern I think that this issue also ties in with #586

samtstern commented 5 years ago

@the-dagger I can confirm we're making some internal progress on #586, I've seen some good API proposals going around!

the-dagger commented 5 years ago

Awesome, thanks!

FarshidRoohi commented 5 years ago

I also have this problem(any devices) there is a solution?

implementation 'com.google.firebase:firebase-core:16.0.6' implementation 'com.google.firebase:firebase-ml-vision:18.0.2'

take image and call method

   mCamera.takePicture(null, null, new Camera.PictureCallback() {
     @Override
       public void onPictureTaken(byte[] bytes, Camera camera) {
              Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
               ByteArrayOutputStream stream = new ByteArrayOutputStream();
               bitmap.compress(Bitmap.CompressFormat.JPEG, 1, stream);
               imageView.setImageBitmap(bitmap);
               fetch(bitmap);
     }
 });
 private void fetch(Bitmap bitmap) {
        final FirebaseVisionImage    firebaseVisionImage          = FirebaseVisionImage.fromBitmap(bitmap);
        FirebaseVisionTextRecognizer firebaseVisionTextRecognizer = FirebaseVision.getInstance().getOnDeviceTextRecognizer();

        firebaseVisionTextRecognizer.processImage(firebaseVisionImage)
                .addOnSuccessListener(new OnSuccessListener<FirebaseVisionText>() {
                    @Override
                    public void onSuccess(FirebaseVisionText firebaseVisionText) {
                        btn.setEnabled(true);
                        Log.i(TAG, "onFailure: " + firebaseVisionText.getText());

                    }
                }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                btn.setEnabled(true);
                e.printStackTrace();
                Log.i(TAG, "onFailure: " + e.getMessage());
            }
        });
    }

error message : Waiting for the text recognition model to be downloaded. Please wait.

samtstern commented 5 years ago

There doesn't seem to be evidence here that anything is broken, models can sometimes take a long time to download on a slower or spottier connection. Let's close this and I will update on when we have a better API for these downloads in #586.

hardysim commented 4 years ago

This pops up for me after trying on-device OCR on Android 11 DP 1.

On previous versions, everything worked fine (the models are also mentioned in the manifest to be downloaded via com.google.firebase.ml.vision.DEPENDENCIES).

But it seems that even with FirebaseModelManager I cannot check the status of on-device models (see firebase/firebase-android-sdk#47)?!

Is this a known problem with Android 11?

shubh261096 commented 4 years ago

Add this dependency. It worked for me. implementation 'com.google.firebase:firebase-ml-vision-barcode-model:16.0.2'

hardysim commented 4 years ago

This might be a workaround. But the auto-download will be fixed, right?

@shubh261096 which dependency do I need for OCR?

kDmartel commented 4 years ago

Do you have a workaround? @samtstern samtstern

JeetSA commented 4 years ago

I am having the same issue. Can anyone please help me?

Anku5hk commented 3 years ago

Add this dependency. It worked for me. implementation 'com.google.firebase:firebase-ml-vision-barcode-model:16.0.2'

Does not work, it shows duplicate classes when using mlkit's ocr. Anyone solved the issue?

Anku5hk commented 3 years ago

The problem seems to be of play services version, on emulator it's not working but on physical device it is. Anyone having problem should check that one.

hojat72elect commented 2 years ago

This problem isn't specific to emulators; it happens on "Samsung S20" and OnePlus devices as well. Does anyone has a solution?

deniscoman commented 2 years ago

Still seeing this issue. Does anyone found any solution?

MSchmidt commented 2 years ago

I'm seeing an increasing number of users that report broken OCR. For many it has started with a recent Android Update but I cannot reproduce it.

It's fixable by clearing all google play services data on affected devices, but how are we supposed to communicate this towards end-users.

jmazier-j2d commented 2 years ago

I'm experiencing this issue on many many recent Android devices (11 & 12)... The download just fail somehow, waiting is not an option (it just won't download).

rodgomesc commented 2 years ago

how i fixed this,

so far i found 3 scenarios that can cause this problem:

1 - your android emulator is not a version that include google play services.
2 - google play store need to be logged to be able to download the model
3 - your google play services is not updated on emulator or physical devices

Important note

those steps solved for me

1 - updated google play services

2 - stop your app and clear all data and cache

3 - Signin in Google Play

4 - Open your App again!