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

EasyOCR is not giving output and exiting before printing anything and also no error on console!!!! #1362

Open
Ctmax-ui opened this issue Jan 9, 2025 · 10 comments

Comments

@Ctmax-ui
Copy link

Ctmax-ui commented Jan 9, 2025

When i run the code it just exiting halfway there not even giving output, please help me

my system config:

  • Python 3.12.8
  • windows 10
  • i5 3gen
  • 8gb ram
  • 730 NVidia gpu
  • 256 SSD

project structure:
image

input images:
d
image

code:

import torch
import easyocr
import cv2

print(f"PyTorch version: {torch.__version__}")
print(f"EasyOCR version: {easyocr.__version__}")
print(f"OpenCV version: {cv2.__version__}")

try:
    reader = easyocr.Reader(['en'])
    result = reader.readtext('input/d.png')
    print(result)
    result = reader.readtext('input/image.jpg')
    print(f"OCR Result: {result}")
except Exception as e:
    print(f"An error occurred: {e}")

output:

PS C:\Users\user\Desktop\my-projects\random-stuff\python-image-translator> python .\testocr.py
PyTorch version: 2.5.1+cpu
EasyOCR version: 1.7.2
OpenCV version: 4.10.0
Neither CUDA nor MPS are available - defaulting to CPU. Note: This module is much faster with a GPU.
PS C:\Users\user\Desktop\my-projects\random-stuff\python-image-translator> 
PS C:\Users\user\Desktop\my-projects\random-stuff\python-image-translator> python .\testocr.py
PyTorch version: 2.5.1+cpu
EasyOCR version: 1.7.2
OpenCV version: 4.10.0
Neither CUDA nor MPS are available - defaulting to CPU. Note: This module is much faster with a GPU.
PS C:\Users\user\Desktop\my-projects\random-stuff\python-image-translator> 
@Maryam483
Copy link

yes same issue with me, the code works fine on Colab with CPU setting but not on laptop

@Ctmax-ui
Copy link
Author

yes same issue with me, the code works fine on Colab with CPU setting but not on laptop

and the worst part is, not giving any error !!!

@Maryam483
Copy link

Maryam483 commented Jan 15, 2025

then how we solve this issue ?? there is no help on internet

@Ctmax-ui
Copy link
Author

then how we solve this issue ?? there is no help on internet

No idea, maybe you could try to reinstall your os.

@ssotobayashi-m
Copy link

I'm not sure if it's related to this issue, but in my environment I've encountered a situation where it seems to hang inside reader.readtext. It appears to work with PyTorch 2.2.0, but there have been cases where it doesn't work properly with PyTorch 2.2.1, 2.2.2, and 2.3.0.

@Ctmax-ui
Copy link
Author

with PyTorch 2.2.0, but there have been cases where it doesn't work properly w

please do tell us if you fix the issue.

@ssotobayashi-m
Copy link

FYI, in my case, it appeared to hang when calling toTensor in NormalizePAD. https://github.com/JaidedAI/EasyOCR/blob/master/easyocr/recognition.py#L39

However, it doesn't always happen, and since the issue occurred with a certain PIL Image that didn't seem particularly problematic, I still don't really know the cause at this point.

@ssotobayashi-m
Copy link

First and foremost, it appears to run without any issues on Linux.

I was testing in an Apple M1 environment, and I observed the following behavior as far as my usage was concerned; The Python version did not seem to have a significant impact, so I will omit it for now (I actually conducted experiments using Python 3.9, 3.11, and 3.12.). Additionally, in my environment, the specific points where the program freezes seemed to vary slightly depending on the input data.

Does it depend on the OS version?

Ventura (13.5.2) Sequoia (15.3.1)
PyTorch 2.2.0 OK OK
PyTorch 2.3.0 NG NG

Looking at these results, the OS version does not seem to be a major factor.

Is there a potential issue with the CPU?

Next, I conducted an experiment using Docker to run aarch64 Debian "bullseye" on Sequoia (15.3.1) + M1.

Debian “bullseye” on Sequoia (15.3.1) + M1
PyTorch 2.3.0 OK

Based on this result, the fact that the CPU is M1 also does not seem to be a determining factor.

While the cause remains unknown, in environments where the issue occurs, one possible workaround could be to use Docker or WSL2 on Windows, or Docker on Mac, to create a Linux environment and run EasyOCR within it.

@Ctmax-ui
Copy link
Author

ok thanks for the info, lets see if i can run in docker, can you provide the docker file

@ssotobayashi-m
Copy link

I will include the Dockerfile that I had ChatGPT generate based on what I needed and then manually refined it. I started the docker container, installed additional necessary libraries inside it, and tested an application including EasyOCR. The reason I am using Python 3.11 instead of the latest version is that, in addition to EasyOCR, I am also using an other library that is not yet compatible with Python 3.12.

FROM python:3.11.11-bullseye

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y \
    git \
    build-essential

RUN python -m pip install --upgrade pip

WORKDIR /work

RUN python -m venv /venv

ENV PATH="/venv/bin:$PATH"

RUN /venv/bin/pip install -U pip matplotlib jupyter jupyterlab

COPY jupyter_lab_config.py /root/.jupyter/

CMD ["python"]

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

3 participants