错误由来
im = im.resize((w, h), Image.ANTIALIAS)
Traceback (most recent call last):
AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'
import PIL
print(PIL.__version__)
10.0.1
原因是在pillow的10.0.0版本中,ANTIALIAS方法被删除了,使用新的方法即可:
Image.LANCZOS
Image.Resampling.LANCZOS
解决办法
方案一,修改方法调用,将其中的ANTIALIAS
替换为LANCZOS
:
# im = im.resize((w, h), Image.ANTIALIAS)
im = im.resize((w, h), Image.LANCZOS)
方案二,降级Pillow的版本,如9.5.0版本
卸载再重新安装
pip uninstall -y Pillow
pip install Pillow==9.5.0
- 39 AttributeError ANTIALIAS attribute module39 attributeerror antialias attribute 39 attributeerror attribute module attributeerror antialias attribute ddddocr 39 quot attributeerror attribute 39 attributeerror attribute nonetype 39 attributeerror tensorflow attribute hydra attributeerror attribute module 39 attributeerror attribute copy_src 39 attributeerror attribute深度 v_flag_cb_issuer_check 39 attributeerror attribute