Open CdAB63 opened 1 year ago
Id does not seem to be related to opencv but to torch (where the fail happens)
Fixed the problem retrofitting torch and torchvision
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
import torch print(torch.version) 2.0.1 import torchvision print(torchvision.version) 0.15.2 import easyocr reader = easyocr.Reader(['pt']) Neither CUDA nor MPS are available - defaulting to CPU. Note: This module is much faster with a GPU.
I've noticed that on a cpu and current versions of torch you get a segfault, but this can be avoided by passing quantize=False
when instantiating the Reader
. Specifically, it looks like this line: https://github.com/JaidedAI/EasyOCR/blob/master/easyocr/recognition.py#L177 doesn't pass through the device (e.g., I think (but am not certain), that it should be torch.quantization.quantize_dynamic(model, {'device': device}, dtype=torch.qint8, inplace=True)
).
But I don't see quantize
in the official docs, so I'm not sure what implication this has.
And, in looking at this, I wonder why this line https://github.com/JaidedAI/EasyOCR/blob/master/easyocr/easyocr.py#L89 has a comma at the end. It seems like it makes self.quantize
a tuple.
I've noticed that on a cpu and current versions of torch you get a segfault, but this can be avoided by passing
quantize=False
when instantiating theReader
. Specifically, it looks like this line: https://github.com/JaidedAI/EasyOCR/blob/master/easyocr/recognition.py#L177 doesn't pass through the device (e.g., I think (but am not certain), that it should betorch.quantization.quantize_dynamic(model, {'device': device}, dtype=torch.qint8, inplace=True)
).But I don't see
quantize
in the official docs, so I'm not sure what implication this has.And, in looking at this, I wonder why this line https://github.com/JaidedAI/EasyOCR/blob/master/easyocr/easyocr.py#L89 has a comma at the end. It seems like it makes
self.quantize
a tuple.
Thank you so much! Adding 'quantize=False' when instantiating the Reader, solve the problem of crash when using reader.readtext() for me.
reader = easyocr.Reader(['en'], gpu=False, quantize=False)
Good night.
EasyOCR is crashing the Python 3.10 VM Ubuntu 22.04 / Debian Bullseye (identical problem but Python 3.9) Architecture Raspberry Pi 4 4GBytes
Error as follows:
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux Type "help", "copyright", "credits" or "license" for more information.
Current thread 0x0000ffff949d3420 (most recent call first): File "/home/cdab63/.local/lib/python3.10/site-packages/torch/_ops.py", line 692 in call File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/nn/quantized/dynamic/modules/rnn.py", line 119 in init File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/nn/quantized/dynamic/modules/rnn.py", line 400 in init File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/nn/quantized/dynamic/modules/rnn.py", line 291 in from_float File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/nn/quantized/dynamic/modules/rnn.py", line 495 in from_float File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/quantization/quantize.py", line 623 in swap_module File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/quantization/quantize.py", line 590 in _convert File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/quantization/quantize.py", line 588 in _convert File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/quantization/quantize.py", line 588 in _convert File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/quantization/quantize.py", line 550 in convert File "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/quantization/quantize.py", line 465 in quantize_dynamic File "/home/cdab63/.local/lib/python3.10/site-packages/easyocr/recognition.py", line 177 in get_recognizer File "/home/cdab63/.local/lib/python3.10/site-packages/easyocr/easyocr.py", line 231 in init File "", line 1 in
Extension modules: PIL._imaging, numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, torch._C, torch._C._fft, torch._C._linalg, torch._C._nested, torch._C._nn, torch._C._sparse, torch._C._special, PIL._imagingft, cv2.cv2, scipy._lib._ccallback_c, scipy.ndimage._nd_image, scipy.special._ufuncs_cxx, scipy.special._ufuncs, scipy.special._specfun, scipy.special._comb, scipy.linalg._fblas, scipy.linalg._flapack, scipy.linalg.cython_lapack, scipy.linalg._cythonized_array_utils, scipy.linalg._solve_toeplitz, scipy.linalg._decomp_lu_cython, scipy.linalg._matfuncs_sqrtm_triu, scipy.linalg.cython_blas, scipy.linalg._matfuncs_expm, scipy.linalg._decomp_update, scipy.sparse._sparsetools, _csparsetools, scipy.sparse._csparsetools, scipy.sparse.linalg._isolve._iterative, scipy.sparse.linalg._dsolve._superlu, scipy.sparse.linalg._eigen.arpack._arpack, scipy.sparse.csgraph._tools, scipy.sparse.csgraph._shortest_path, scipy.sparse.csgraph._traversal, scipy.sparse.csgraph._min_spanning_tree, scipy.sparse.csgraph._flow, scipy.sparse.csgraph._matching, scipy.sparse.csgraph._reordering, scipy.linalg._flinalg, scipy.special._ellip_harm_2, _ni_label, scipy.ndimage._ni_label, skimage._shared.geometry, yaml._yaml (total: 58) Segmentation fault (core dumped)