1. 11 Jun, 2020 2 commits
  2. 10 Jun, 2020 1 commit
  3. 04 Jun, 2020 2 commits
  4. 18 May, 2020 2 commits
    • Steven Basart's avatar
      Add pil_to_tensor to functionals (#2092) · e6d3f8c5
      Steven Basart authored
      * Adds as_tensor to functional.py
      
      Similar functionality to to_tensor without the default conversion to float and division by 255.
      Also adds support for Image mode 'L'.
      
      * Adds tests to AsTensor()
      
      Adds tests to AsTensor and removes the conversion to float and division by 255.
      
      * Adds AsTensor to transforms.py
      
      Calls the as_tensor function in functionals and adds the function AsTensor as callable from transforms.
      
      * Removes the pic.mode == 'L'
      
      This was handled by the else condition previously so I'll remove it.
      
      * Fix Lint issue
      
      Adds two line breaks between functions to fix lint issue
      
      * Replace from_numpy with as_tensor
      
      Removes the extra if conditionals and replaces from_numpy with as_tensor.
      
      * Renames as_tensor to pil_to_tensor
      
      Renames the function as_tensor to pil_to_tensor and narrows the scope of the function.  At the same time also creates a flag that defaults to True for swapping to the channels first format.
      
      * Renames AsTensor to PILToImage
      
      Renames the function AsTensor to PILToImage and modifies the description.  Adds the swap_to_channelsfirst boolean variable to indicate if the user wishes to change the shape of the input.
      
      * Add the __init__ function to PILToTensor 
      
      Add the __init__ function to PILToTensor since it contains the swap_to_channelsfirst parameter now.
      
      * fix lint issue
      
      remove trailing white space
      
      * Fix the tests
      
      Reflects the name change to PILToTensor and the parameter to the function as well as the new narrowed scope that the function only accepts PIL images.
      
      * fix tests
      
      Instead of undoing the transpose just create a new tensor and test that one.
      
      * Add the view back
      
      Add img.view(pic.size[1], pic.size[0], len(pic.getbands())) back to outside the if condition.
      
      * fix test
      
      fix conversion from torch tensor to PIL back to torch tensor.
      
      * fix lint issues
      
      * fix lint
      
      remove trailing white space
      
      * Fixed the channel swapping tensor test
      
      Torch tranpose operates differently than numpy transpose.  Changed operation to permute.
      
      * Add mode='F'
      
      Add mode information when converting to PIL Image from Float Tensor.
      
      * Added inline comments to follow shape changes
      
      * ToPILImage converts FloatTensors to uint8
      
      * Remove testing not swapping
      
      * Removes the swap_channelsfirst parameter
      
      Makes the channel swapping the default behavior.
      
      * Remove the swap_channelsfirst argument
      
      Remove the swap_channelsfirst argument and makes the swapping the default functionality.
      e6d3f8c5
    • Francisco Massa's avatar
      Fix Python lint (#2226) · e2e511be
      Francisco Massa authored
      e2e511be
  5. 05 May, 2020 1 commit
  6. 04 May, 2020 1 commit
  7. 03 Apr, 2020 1 commit
  8. 02 Apr, 2020 1 commit
  9. 01 Apr, 2020 2 commits
  10. 31 Mar, 2020 1 commit
  11. 30 Mar, 2020 1 commit
  12. 24 Mar, 2020 1 commit
  13. 23 Mar, 2020 2 commits
  14. 27 Feb, 2020 1 commit
  15. 25 Feb, 2020 1 commit
    • Phoenix Meadowlark's avatar
      Improved error messages for transforms.functional.normalize(). (#1915) · 2f433e0a
      Phoenix Meadowlark authored
      * Improved error messages for transforms.functional.normalize().
      
      Split the original TypeError into 1. a TypeError if `tensor` is not a torch.Tensor and 2. a ValueError if `tensor` does not have the correct dimensionality.
      
      Added more detail to the error for when `tensor` has the wrong dimension to make it easier to diagnose. This is useful when this function isn't called directly by the user (e.g. when the user uses transforms.Normalize and can't directly see this functions doc string).
      
      Deleted hanging function `_is_tensor_image()`. It isn't used in this file and isn't used internally anywhere else in torchvision that I can see. (Some users will have used it despite the underscore prefix, but a quick google search for "F._is_tensor_image" suggests this is rare).
      
      * Value checking to prevent division by zero runtime crashes.
      
      Added a ValueError to check for and avoid division by zero in `div_`. Not preventing the call leads to runtime crashes, at least in some environments.
      
      * Fixed div by zero check for non-scalar inputs.
      2f433e0a
  16. 10 Feb, 2020 1 commit
  17. 29 Jan, 2020 1 commit
  18. 27 Jan, 2020 1 commit
    • abdjava's avatar
      Fixed typo in comments (#1784) · 035ed162
      abdjava authored
      I have fixed a typo that was persent in the Normalize class changed line 150 from     ``input[channel] = (input[channel] - mean[channel]) / std[channel]`` to     ``output[channel] = (input[channel] - mean[channel]) / std[channel]``
      035ed162
  19. 22 Jan, 2020 2 commits
  20. 19 Dec, 2019 1 commit
  21. 04 Dec, 2019 1 commit
  22. 05 Nov, 2019 1 commit
    • Ankit Jha's avatar
      [WIP] Add Scriptable Transform: Grayscale (#1505) · 8909ff43
      Ankit Jha authored
      * Add Scriptable Transform: Grayscale
      
      * add scriptable transforms: rgb_to_grayscale
      
      * add scriptable transform: rgb_to_grayscale
      
      * add scriptable transform: rgb_to_grayscale
      
      * add scriptable transform: rgb_to_grayscale
      
      * update code: rgb_to_grayscale
      
      * add test: rgb_to_grayscale
      
      * update parameters: rgb_to_grayscale
      
      * add scriptable transform: rgb_to_grayscale
      
      * update rgb_to_grayscale
      
      * update rgb_to_grayscale
      8909ff43
  23. 29 Oct, 2019 1 commit
    • pedrofreire's avatar
      Make shear operation area preserving (#1529) · c226bb95
      pedrofreire authored
      * Improve readability of affine transformation code
      
      * Make shear transformation area preserving
      
      The previous shear implementation did not preserve area, and we
      implement a version that does.
      
      The formula used was verified with the following sympy code:
      
      from sympy import Matrix, cos, sin, tan, simplify
      from sympy.abc import x, y, phi
      
      Xs = Matrix(
              [[1, -tan(x)],
               [0, 1]]
              )
      
      Ys = Matrix(
              [[1, 0],
               [-tan(y), 1]]
              )
      
      R = Matrix(
              [[cos(phi), -sin(phi)],
               [sin(phi), cos(phi)]]
              )
      
      RSS = Matrix(
              [[cos(phi - y)/cos(y), -cos(phi - y)*tan(x)/cos(y) - sin(phi)],
               [sin(phi - y)/cos(y), -sin(phi - y)*tan(x)/cos(y) + cos(phi)]])
      
      print(simplify(R * Ys * Xs - RSS))
      
      One thing that is not clear (and could be tested) is whether avoiding
      the explicit products and calculations in _get_inverse_affine_matrix
      really gives performance benefits - compared to doing the explicit
      calculation done in _test_transformation.
      
      * Use np.matmul instead of @
      
      The @ syntax is not supported in Python 2.
      c226bb95
  24. 26 Oct, 2019 1 commit
    • pedrofreire's avatar
      Add adjustment operations for RGB Tensor Images. (#1525) · e79caddf
      pedrofreire authored
      * Add adjustment operations for RGB Tensor Images.
      
      Right now, we have operations on PIL images, but we want to have a version of the opeartions that act directly on Tensor images.
      
      Here, we add such operations for adjust_brightness, adjust_contrast and adjust_saturation.
      
      In PIL, those functions are implemented by generating an degenerate image from the first, and then interpolating them together.
      - https://github.com/python-pillow/Pillow/blob/master/src/PIL/ImageEnhance.py
      - https://github.com/python-pillow/Pillow/blob/master/src/libImaging/Blend.c
      
      A few caveats:
      * Since PIL operates on uint8, and the tensor operations might be on float, we can get slightly different values because of int truncation.
      * We assume here the images are RGB; in particular, to handle an alpha channel, we need to check whether it is present, in which case we copy it to the final image.
      
      * Keep dtype and use broadcast in adjust operations
      
      - We make our operations have input.dtype == output.dtype, at the cost of
      adding a few type checks and branches.
      
      - By using Tensor broadcast, we can simplify the calls to _blend.
      
      * Use is_floating_point to check dtype.
      
      * Remove unpacking in tuple
      
      It seems Python 2 does not support this type of unpacking, so it broke
      Python 2 builds. This should fix it.
      
      * Add from __future__ import division for Python 2
      e79caddf
  25. 18 Oct, 2019 2 commits
    • ekka's avatar
      Make crop scriptable (#1379) · d194082c
      ekka authored
      * Make crop torchscriptable
      
      Relevant #1375
      
      * Invert x and y axis
      
      * fix lint
      
      * Add crop test
      
      * revert deletion of space in functional
      
      * add import random
      
      * add dimension in doc
      
      * add import
      
      * fix flake8
      
      * change to self.assert*
      
      * convert to uint8
      
      * assertTrue
      
      * lint
      d194082c
    • Surgan Jandial's avatar
      PILLOW_VERSION deprecation updates (#1501) · b8ef5322
      Surgan Jandial authored
      * doc-build fixed
      
      * deprecation fixes
      
      * deprecation updates
      b8ef5322
  26. 16 Oct, 2019 1 commit
  27. 08 Oct, 2019 1 commit
  28. 30 Sep, 2019 1 commit
  29. 24 Sep, 2019 1 commit
    • Zhicheng Yan's avatar
      Video transforms (#1353) · 64917bcc
      Zhicheng Yan authored
      * video transforms
      
      * [video transforms]in ToTensorVideo, divide value by 255.0
      
      * [video transforms] fix a bug
      
      * fix linting
      
      * Make changes backwards-compatible
      64917bcc
  30. 11 Sep, 2019 1 commit
  31. 06 Sep, 2019 1 commit
  32. 30 Aug, 2019 1 commit
  33. 09 Jul, 2019 1 commit