EasyOCR is an end-to-end multi-lingual optical character recognition (OCR) solution designed for ease of use. It supports over 80 languages and provides pre-trained models for common use cases. The current version is 1.7.2, with minor releases focusing on compatibility and bug fixes, and major updates introducing new features like detector networks or Apple Silicon support.
pip install easyocrVerified import paths — ran on the pinned version, not inferred.
This quickstart code creates a simple dummy image with text, then initializes an EasyOCR Reader for English and French. The first time you run this for a new language, it will download the necessary language models. It then performs OCR on the image and prints the detected text along with its confidence score. For GPU acceleration, ensure you have correctly installed PyTorch with CUDA support and set `gpu=True`.
After installing easyocr, install PyTorch with CUDA from the official PyTorch website based on your CUDA version (e.g., `pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118`). Then, initialize `easyocr.Reader(..., gpu=True)`.
Ensure an active internet connection on first use. For production, consider pre-downloading models or packaging them with your application (refer to EasyOCR documentation for model locations).
Consult the official EasyOCR GitHub repository for the list of supported languages. If your language is not supported or performs poorly, consider training a custom model.
To use DBNET, initialize `reader = easyocr.Reader(['en'], detect_network='dbnet18')`. If you need to ensure the CRAFT detector (the default prior to v1.6.0), you can explicitly set `detect_network='craft'`.
For large images, consider pre-processing to resize or split them. For memory-constrained environments, run on CPU (`gpu=False`) and process images in batches or sequentially. Monitor resource usage and adjust configurations accordingly.
Install easyocr using pip: `pip install easyocr`. If using a virtual environment, ensure it is activated before installation. For issues related to `torch.backends`, try reinstalling `torch` first, ensuring you select the correct version for your Python environment and hardware (e.g., CUDA-enabled if applicable), and then reinstall `easyocr`.
Verify the image file path is correct and absolute, ensure the file exists and is not corrupted, and check that the Python process has read access to the file. You can debug this by attempting to load the image directly with OpenCV (e.g., `img = cv2.imread('your_image.jpg'); print(img)`) to confirm it's not `None` before passing it to EasyOCR.Ensure you have an NVIDIA GPU, up-to-date GPU drivers, and a compatible CUDA Toolkit installed. Install a CUDA-enabled version of PyTorch by following the official installation instructions on the PyTorch website (select your OS, CUDA version, etc.) before installing EasyOCR. If you already have PyTorch, consider reinstalling it with CUDA support: `pip uninstall torch torchvision torchaudio` then `pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cuXXX` (replace `XXX` with your CUDA version, e.g., `cu118`).
Downgrade the Pillow library to a version prior to 10.0.0, for example: `pip install Pillow==9.5.0`. Alternatively, if you wish to use a newer Pillow version, you might need to update EasyOCR to its latest version or manually modify the EasyOCR source code (e.g., in `utils.py` around line 576 as seen in some older versions) to replace `Image.ANTIALIAS` with `Image.LANCZOS` or `Image.Resampling.LANCZOS` (for Pillow 9.1.0+).