diff --git a/.travis.yml b/.travis.yml index 99d3562b74c..15b2f3b14ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,17 @@ language: python -python: - - "2.7" - - "3.5" + +matrix: + include: + - env: LINT_CHECK + python: "2.7" + install: pip install flake8 + script: flake8 + - python: "2.7" + env: IMAGE_BACKEND=Pillow-SIMD + - python: "2.7" + - python: "3.5" + env: IMAGE_BACKEND=Pillow-SIMD + - python: "3.5" install: - sudo apt-get update @@ -18,13 +28,9 @@ install: - source activate test-environment - python setup.py install - pip install --upgrade pytest - + - if [[ "$IMAGE_BACKEND" == "Pillow-SIMD" ]]; then + pip uninstall -y pillow && CC="cc -march=native" pip install --force-reinstall pillow-simd; + fi script: - pytest test/ -matrix: - include: - - env: LINT_CHECK - python: "2.7" - install: pip install flake8 - script: flake8 diff --git a/docs/source/transforms.rst b/docs/source/transforms.rst index a05df77151d..c6cbb42ecfc 100644 --- a/docs/source/transforms.rst +++ b/docs/source/transforms.rst @@ -40,6 +40,8 @@ Transforms on PIL Image .. autoclass:: RandomRotation +.. autoclass:: RandomAffine + Transforms on torch.\*Tensor ---------------------------- diff --git a/torchvision/transforms/functional.py b/torchvision/transforms/functional.py index 921826cb3c6..db2f5e60dc7 100644 --- a/torchvision/transforms/functional.py +++ b/torchvision/transforms/functional.py @@ -2,7 +2,7 @@ import torch import math import random -from PIL import Image, ImageOps, ImageEnhance +from PIL import Image, ImageOps, ImageEnhance, PILLOW_VERSION try: import accimage except ImportError: @@ -604,7 +604,7 @@ def affine(img, angle, translate, scale, shear, resample=0, fillcolor=None): An optional resampling filter. See http://pillow.readthedocs.io/en/3.4.x/handbook/concepts.html#filters If omitted, or if the image has mode "1" or "P", it is set to PIL.Image.NEAREST. - fillcolor (int): Optional fill color for the area outside the transform in the output image. + fillcolor (int): Optional fill color for the area outside the transform in the output image. (Pillow>=5.0.0) """ if not _is_pil_image(img): raise TypeError('img should be PIL Image. Got {}'.format(type(img))) @@ -617,7 +617,8 @@ def affine(img, angle, translate, scale, shear, resample=0, fillcolor=None): output_size = img.size center = (img.size[0] * 0.5 + 0.5, img.size[1] * 0.5 + 0.5) matrix = _get_inverse_affine_matrix(center, angle, translate, scale, shear) - return img.transform(output_size, Image.AFFINE, matrix, resample, fillcolor=fillcolor) + kwargs = {"fillcolor": fillcolor} if PILLOW_VERSION[0] == '5' else {} + return img.transform(output_size, Image.AFFINE, matrix, resample, **kwargs) def to_grayscale(img, num_output_channels=1): diff --git a/torchvision/transforms/transforms.py b/torchvision/transforms/transforms.py index 9fc09d3a34d..6f81e8b21d2 100644 --- a/torchvision/transforms/transforms.py +++ b/torchvision/transforms/transforms.py @@ -828,7 +828,7 @@ class RandomAffine(object): An optional resampling filter. See http://pillow.readthedocs.io/en/3.4.x/handbook/concepts.html#filters If omitted, or if the image has mode "1" or "P", it is set to PIL.Image.NEAREST. - fillcolor (int): Optional fill color for the area outside the transform in the output image. + fillcolor (int): Optional fill color for the area outside the transform in the output image. (Pillow>=5.0.0) """ def __init__(self, degrees, translate=None, scale=None, shear=None, resample=False, fillcolor=0):