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

Crash when running ocr_predictor #1871

Open
decisivemoment64 opened this issue Feb 13, 2025 · 8 comments
Open

Crash when running ocr_predictor #1871

decisivemoment64 opened this issue Feb 13, 2025 · 8 comments
Labels
type: bug Something isn't working

Comments

@decisivemoment64
Copy link

decisivemoment64 commented Feb 13, 2025

Bug description

Hello,
Python crashes when I run ocr_predictor() (whatever the arguments). I can see the download advancement until about 28%, then Python is unresponsive. I run it on a MacBook Pro (M1).
Sorry if I'm just doing something wrong, and thank you for your help!

Code snippet to reproduce the bug

from doctr.models import ocr_predictor

model = ocr_predictor(det_arch='db_resnet50', reco_arch='crnn_vgg16_bn', pretrained=True)

Error traceback

No error message, but the application is unresponsive.

Environment

DocTR version: v0.11.0
TensorFlow version: 2.18.0
PyTorch version: 2.6.0 (torchvision 0.21.0)
OpenCV version: 4.11.0
OS: Mac OSX 15.0
Python version: 3.12.6
Is CUDA available (TensorFlow): No
Is CUDA available (PyTorch): No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA

Deep Learning backend

is_tf_available: True
is_torch_available: True
@decisivemoment64 decisivemoment64 added the type: bug Something isn't working label Feb 13, 2025
@decisivemoment64 decisivemoment64 changed the title Crash when getting the pretrained model Crash when running ocr_predictor Feb 13, 2025
@felixdittrich92
Copy link
Contributor

Hi @decisivemoment64 👋 ,

Thanks for reporting 👍

Sounds a bit weird to be honest 😅 Do you have enough free space on your device and a stable internet connection ?

@decisivemoment64
Copy link
Author

decisivemoment64 commented Feb 14, 2025

Hi @decisivemoment64 👋 ,

Thanks for reporting 👍

Sounds a bit weird to be honest 😅 Do you have enough free space on your device and a stable internet connection ?

Thank you for the quick reply! I have more than 100 Go available, could that be too little? I think that my internet connection is fine

@felixdittrich92
Copy link
Contributor

Hi @decisivemoment64 👋 ,
Thanks for reporting 👍
Sounds a bit weird to be honest 😅 Do you have enough free space on your device and a stable internet connection ?

Thank you for the quick reply! I have more than 100 Go available, could that be too little? I think that my internet connection is fine

That's more as enough !

We store the downloaded models in ~/.cache/doctr could you delete this folder and try it again ?
And there was no error traceback or any kind of error ?

@decisivemoment64
Copy link
Author

decisivemoment64 commented Feb 14, 2025

Hi @decisivemoment64 👋 ,
Thanks for reporting 👍
Sounds a bit weird to be honest 😅 Do you have enough free space on your device and a stable internet connection ?

Thank you for the quick reply! I have more than 100 Go available, could that be too little? I think that my internet connection is fine

That's more as enough !

We store the downloaded models in ~/.cache/doctr could you delete this folder and try it again ? And there was no error traceback or any kind of error ?

Unfortunately deleting the folder didn't work!
I tried to wait, and after a while I got the system error "Your system has run out of application memory." Could it be that 16Go of RAM is not enough? (it says that IDLE is taking up about 54 GB of application memory)

EDIT: I tried uninstalling everything and reinstalling with the latest version of Python. Now IDLE does not become unresponsive but the downloading speed gets slower and slower at each iteration (down to less than 20it/s). It keeps going but it is so slow that it's only 12% after running for half an hour.

@felixdittrich92
Copy link
Contributor

It's also more than enough 😅

Sounds all really weird... Could you please try https://github.com/felixdittrich92/OnnxTR and respond if the same behaviour happens ?

@decisivemoment64
Copy link
Author

It's also more than enough 😅

Sounds all really weird... Could you please try https://github.com/felixdittrich92/OnnxTR and respond if the same behaviour happens ?

Yes, same behavior... However, to add to the weirdness, I noticed that how far I could go in the download before it slowed down dramatically depended on the internet network as was connected to 🤔

@decisivemoment64
Copy link
Author

I dug a bit further and it turns out that the problem stems from the update of the progress bar in the tqdm package. I replicated the _urlretrieve function and arguments to try to download the pretrained model file. It works perfectly if I comment out the command "pbar.update(chunk_size)", but it bugs if I keep it.

@felixdittrich92
Copy link
Contributor

Hi @decisivemoment64 👋

Thanks for the update ... sounds like an issue with python's multiproc on your Mac machine .. but unfortunately I don't think there is anything we could do from our end..

Another thing you could try is how it looks with downloading the models from the HF hub.

For example:

from doctr.io import DocumentFile
from doctr.models import ocr_predictor, from_hub
image = DocumentFile.from_images(['data/example.jpg'])
# Load a custom detection model from huggingface hub
det_model = from_hub('Felix92/doctr-torch-db-mobilenet-v3-large')
# Load a custom recognition model from huggingface hub
reco_model = from_hub('Felix92/doctr-torch-crnn-mobilenet-v3-large-french')
# You can easily plug in this models to the OCR predictor
predictor = ocr_predictor(det_arch=det_model, reco_arch=reco_model)
result = predictor(image)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants