EasyOCR在Python 3.10 VM上崩溃了
Ubuntu 22.04 / Debian Bullseye(问题相同,但Python版本为3.9)
架构:树莓派4 4GBytes
错误如下:
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
输入“help”,“copyright”,“credits”或“license”以获取更多信息。
import faulthandler
import easyocr
faulthandler.enable()
reader = easyocr.Reader(['pt'])
Neither CUDA nor MPS are available - defaulting to CPU. Note: This module is much faster with a GPU.
Fatal Python error: Segmentation fault
当前线程0x0000ffff949d3420 (最近调用者首先):
文件 "/home/cdab63/.local/lib/python3.10/site-packages/torch/_ops.py", line 692 in call
文件 "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/nn/quantized/dynamic/modules/rnn.py", line 119 in init
文件 "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/nn/quantized/dynamic/modules/rnn.py", line 400 in init
文件 "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/nn/quantized/dynamic/modules/rnn.py", line 291 in from_float
文件 "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/quantization/quantize.py", line 623 in swap_module
文件 "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/quantization/quantize.py", line 590 in _convert
文件 "/home/cdab63/.local/lib/python3.10/site-packages/torch/ao/quantization/quantize.py", line 588 in _convert
文件 "/home/cdab63/.local/lib/python3.10/site-packages/easyocr/recognition.py", line 177 in get_recognizer
文件 "/home/cdab63/.local/lib/python3.10/site-packages/easyocr/easyocr.py", line 231 in init
文件 "",行1 in
扩展模块: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
3条答案
按热度按时间bmp9r5qi1#
Id似乎与opencv无关,而是与torch(失败发生的地方)有关。
mkshixfv2#
修复了在torch和torchvision中进行改装的问题。
htrmnn0y3#
我已经注意到,在CPU和当前版本的torch中,示例化
Reader
时会出现段错误,但可以通过传递quantize=False
来避免这个问题。具体来说,这行代码:https://github.com/JaidedAI/EasyOCR/blob/master/easyocr/recognition.py#L177 并没有通过设备(例如,我认为(但不确定),应该是torch.quantization.quantize_dynamic(model, {'device': device}, dtype=torch.qint8, inplace=True)
)。但是我在官方文档中没有看到quantize
,所以我不确定这会有什么影响。此外,在研究这个时,我想知道为什么这行代码:https://github.com/JaidedAI/EasyOCR/blob/master/easyocr/easyocr.py#L89 末尾有一个逗号。它似乎使得
self.quantize
成为一个元组。