Skip to content
Merged
Show file tree
Hide file tree
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
26 changes: 16 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
2 changes: 2 additions & 0 deletions docs/source/transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Transforms on PIL Image

.. autoclass:: RandomRotation

.. autoclass:: RandomAffine

Transforms on torch.\*Tensor
----------------------------

Expand Down
7 changes: 4 additions & 3 deletions torchvision/transforms/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)))
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion torchvision/transforms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down