sml2h3 / ddddocr

带带弟弟 通用验证码识别OCR pypi版
https://ddddocr.com/
MIT License
8.94k stars 1.63k forks source link

AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS' #168

Closed hxs9712 closed 4 months ago

hxs9712 commented 4 months ago

Traceback (most recent call last): File "D:\phpstudy_pro\WWW\spider\autoLogin.py", line 48, in res = ocr.classification(img_bytes) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python\Lib\site-packages\ddddocr__init__.py", line 466, in classification image = image.resize((int(image.size[0] * (64 / image.size[1])), 64), Image.ANTIALIAS).convert('L') ^^^^^^^^^^^^^^^ AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

hxs9712 commented 4 months ago

降级可行。 pillow10.2.0与此库不兼容,需要降级到9.5.0,pip install Pillow==9.5.0

lededev commented 2 months ago

改一下lib\site-packages\ddddocr\__init__.py就能支持最新版本的pillow了。

from PIL import Image, ImageChops
import numpy as np
import cv2
from pkg_resources import parse_version

if parse_version(Image.__version__)>=parse_version('10.0.0'):
    Image.ANTIALIAS=Image.LANCZOS