Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PIL Image.ANTIALIAS incompatibility #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cirtorch/datasets/datahelpers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import os
from PIL import Image
from packaging.version import Version

import torch

LANCZOS = Image.LANCZOS if Version(Image.__version__) >= Version("10.0.0") else Image.ANTIALIAS


def cid2filename(cid, prefix):
"""
Creates a training image path out of its CID name
Expand Down Expand Up @@ -40,7 +44,7 @@ def default_loader(path):
return pil_loader(path)

def imresize(img, imsize):
img.thumbnail((imsize, imsize), Image.ANTIALIAS)
img.thumbnail((imsize, imsize), LANCZOS)
return img

def flip(x, dim):
Expand Down