CodeFormer icon indicating copy to clipboard operation
CodeFormer copied to clipboard

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

Open ErfanBahramali opened this issue 2 years ago • 2 comments

Error:

Traceback (most recent call last):
  File "scripts/crop_align_face.py", line 205, in <module>
    size_ = align_face(in_path, out_path)
  File "scripts/crop_align_face.py", line 177, in align_face
    img = img.resize((output_size, output_size), PIL.Image.ANTIALIAS)
AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

The problem is from Pillow version 10.0.0 ANTIALIAS was removed in Pillow 10.0.0 Now you need to use PIL.Image.LANCZOS or PIL.Image.Resampling.LANCZOS Or specify Pillow version in requirements.txt

Pillow==9.5.0

https://stackoverflow.com/questions/76616042/attributeerror-module-pil-image-has-no-attribute-antialias

ErfanBahramali avatar Aug 22 '23 09:08 ErfanBahramali

I am also facing this problem and have already followed the intruction. Even you have changed the property from PIL.Image.LANCZOS or PIL.Image.Resampling.LANCZOS, the output image will be the same as the input.

wonghin avatar Oct 17 '23 09:10 wonghin

Finally, try pip install Pillow==9.4.0 in codeformer conda env. The problem will be solved

wonghin avatar Oct 31 '23 02:10 wonghin