1. 04 Mar, 2021 1 commit
  2. 03 Mar, 2021 1 commit
  3. 15 Feb, 2021 1 commit
  4. 12 Feb, 2021 1 commit
  5. 10 Feb, 2021 1 commit
  6. 09 Feb, 2021 1 commit
  7. 02 Feb, 2021 1 commit
  8. 28 Jan, 2021 1 commit
  9. 14 Dec, 2020 1 commit
    • Vasilis Vryniotis's avatar
      Implement all AutoAugment transforms + Policies (#3123) · 83171d6a
      Vasilis Vryniotis authored
      
      
      * Invert Transform (#3104)
      
      * Adding invert operator.
      
      * Make use of the _assert_channels().
      
      * Update upper bound value.
      
      * Remove private doc from invert, create or reuse generic testing methods to avoid duplication of code in the tests. (#3106)
      
      * Create posterize transformation and refactor common methods to assist reuse. (#3108)
      
      * Implement the solarize transform. (#3112)
      
      * Implement the adjust_sharpness transform (#3114)
      
      * Adding functional operator for sharpness.
      
      * Adding transforms for sharpness.
      
      * Handling tiny images and adding a test.
      
      * Implement the autocontrast transform. (#3117)
      
      * Implement the equalize transform (#3119)
      
      * Implement the equalize transform.
      
      * Turn off deterministic for histogram.
      
      * Fixing test. (#3126)
      
      * Force ratio to be float to avoid numeric overflows on blend. (#3127)
      
      * Separate the tests of Adjust Sharpness from ColorJitter. (#3128)
      
      * Add AutoAugment Policies and main Transform (#3142)
      
      * Separate the tests of Adjust Sharpness from ColorJitter.
      
      * Initial implementation, not-jitable.
      
      * AutoAugment passing JIT.
      
      * Adding tests/docs, changing formatting.
      
      * Update test.
      
      * Fix formats
      
      * Fix documentation and imports.
      
      * Apply changes from code review:
      - Move the transformations outside of AutoAugment on a separate method.
      - Renamed degenerate method for sharpness for better clarity.
      
      * Update torchvision/transforms/functional.py
      Co-authored-by: default avatarvfdev <vfdev.5@gmail.com>
      
      * Apply more changes from code review:
      - Add InterpolationMode parameter.
      - Move all declarations away from AutoAugment constructor and into the private method.
      
      * Update documentation.
      
      * Apply suggestions from code review
      Co-authored-by: default avatarFrancisco Massa <fvsmassa@gmail.com>
      
      * Apply changes from code review:
      - Refactor code to eliminate as any to() and clamp() as possible.
      - Reuse methods where possible.
      - Apply speed ups.
      
      * Replacing pad.
      Co-authored-by: default avatarvfdev <vfdev.5@gmail.com>
      Co-authored-by: default avatarFrancisco Massa <fvsmassa@gmail.com>
      83171d6a
  10. 03 Dec, 2020 1 commit
  11. 27 Nov, 2020 2 commits
  12. 20 Nov, 2020 1 commit
    • Alexey Demyanchuk's avatar
      Add explicit check for number of channels (#3013) · a51c49e4
      Alexey Demyanchuk authored
      
      
      * Add explicit check for number of channels
      
      Example why you need to check it:
      `M = torch.randint(low=0, high=2, size=(6, 64, 64), dtype = torch.float)`
      When you put this input through to_pil_image without mode argument, it converts to uint8 here:
      ```
      if pic.is_floating_point() and mode != 'F':
                  pic = pic.mul(255).byte()
      ```
      and change the mode to RGB here:
      ```
      if mode is None and npimg.dtype == np.uint8:
                  mode = 'RGB'
      ```
      Image.fromarray doesn't raise if provided with mode RGB and just cut number of channels from what you have to 3
      
      * Check number of channels before processing
      
      * Add test for invalid number of channels
      
      * Add explicit check for number of channels
      
      Example why you need to check it:
      `M = torch.randint(low=0, high=2, size=(6, 64, 64), dtype = torch.float)`
      When you put this input through to_pil_image without mode argument, it converts to uint8 here:
      ```
      if pic.is_floating_point() and mode != 'F':
                  pic = pic.mul(255).byte()
      ```
      and change the mode to RGB here:
      ```
      if mode is None and npimg.dtype == np.uint8:
                  mode = 'RGB'
      ```
      Image.fromarray doesn't raise if provided with mode RGB and just cut number of channels from what you have to 3
      
      * Check number of channels before processing
      
      * Add test for invalid number of channels
      
      * Put check after channel dim unsqueeze
      
      * Add test if error message is matching
      
      * Delete redundant code
      
      * Bug fix in checking for bad types
      Co-authored-by: default avatarDemyanchuk <demyanca@mh-hannover.local>
      Co-authored-by: default avatarvfdev <vfdev.5@gmail.com>
      a51c49e4
  13. 18 Nov, 2020 1 commit
    • Vasilis Vryniotis's avatar
      Support specifying output channels in io.image.read_image (#2988) · 4d6ba678
      Vasilis Vryniotis authored
      * Adding output channels implementation for pngs.
      
      * Adding tests for png.
      
      * Adding channels in the API and documentation.
      
      * Fixing formatting.
      
      * Refactoring test_image.py to remove huge grace_hopper_517x606.pth file from assets and reduce duplicate code. Moving jpeg assets used by encode and write unit-tests on their separate folders.
      
      * Adding output channels implementation for jpegs. Fix asset locations.
      
      * Add tests for JPEG, adding the channels in the API and documentation and adding checks for inputs.
      
      * Changing folder for unit-test.
      
      * Fixing windows flakiness, removing duplicate test.
      
      * Replacing components to channels.
      
      * Adding reference for supporting CMYK.
      
      * Minor changes: num_components to output_components, adding comments, fixing variable name etc.
      
      * Reverting output_components to num_components.
      
      * Replacing decoding with generic method on tests.
      
      * Palette converted to Gray.
      4d6ba678
  14. 22 Oct, 2020 2 commits
  15. 14 Oct, 2020 1 commit
  16. 07 Oct, 2020 1 commit
    • Tejan Karmali's avatar
      Added GaussianBlur transform (#2658) · 4106dbb8
      Tejan Karmali authored
      
      
      * Added GaussianBlur transform
      
      * fixed linting
      
      * supports fixed radius for kernel
      
      * [WIP] New API for gaussian_blur
      
      * Gaussian blur with kernelsize and sigma API
      
      * Fixed implementation and updated tests
      
      * Added large input case and refactored gt into a file
      
      * Updated docs
      
      * fix kernel dimesnions order while creating kernel
      
      * added tests for exception handling of gaussian blur
      
      * fix linting, bug in tests
      
      * Fixed failing tests, refactored code and other minor fixes
      Co-authored-by: default avatarvfdev-5 <vfdev.5@gmail.com>
      4106dbb8
  17. 05 Oct, 2020 2 commits
    • vfdev's avatar
      Added CPU/CUDA and batch input for dtype conversion op (#2755) · fdca3073
      vfdev authored
      
      
      * make convert_image_dtype scriptable
      
      * move convert dtype to functional_tensor since only works on tensors
      
      * retain availability of convert_image_dtype in functional.py
      
      * Update code and tests
      
      * Replaced int by torch.dtype
      
      * int -> torch.dtype and use F instead of F_t
      
      * Update functional_tensor.py
      
      * Added CPU/CUDA+batch tests
      
      * Fixed tests according to review
      Co-authored-by: default avatarBrian <nairbv@yahoo.com>
      fdca3073
    • Brian Vaughan's avatar
      make convert_image_dtype scriptable (#2485) · c542137c
      Brian Vaughan authored
      
      
      * make convert_image_dtype scriptable
      
      * move convert dtype to functional_tensor since only works on tensors
      
      * retain availability of convert_image_dtype in functional.py
      
      * Update code and tests
      
      * Replaced int by torch.dtype
      
      * int -> torch.dtype and use F instead of F_t
      
      * Update functional_tensor.py
      Co-authored-by: default avatarvfdev-5 <vfdev.5@gmail.com>
      c542137c
  18. 03 Oct, 2020 1 commit
  19. 30 Sep, 2020 1 commit
    • vfdev's avatar
      Fixes #2702 (#2721) · b618923c
      vfdev authored
      - Updated code and tests to support batch of tensors, e.g. input of shape (B, C, H, W).
      b618923c
  20. 05 Aug, 2020 1 commit
    • vfdev's avatar
      Unified inputs for `F.rotate` (#2495) · 76662528
      vfdev authored
      * Added code for F_t.rotate with test
      - updated F.affine tests
      
      * Rotate test tolerance to 2%
      
      * Fixes failing test
      
      * Optimized _expanded_affine_grid with a single matmul op
      
      * Recoded _compute_output_size
      76662528
  21. 30 Jul, 2020 1 commit
  22. 17 Jul, 2020 1 commit
  23. 16 Jul, 2020 1 commit
    • vfdev's avatar
      Unified input for F.affine (#2444) · 5f4b5794
      vfdev authored
      * [WIP] F.affine
      
      * [WIP] F.affine + tests
      
      * Unified input for F.affine
      
      * Removed commented code
      
      * Removed unused imports
      5f4b5794
  24. 15 Jul, 2020 1 commit
  25. 03 Jul, 2020 1 commit
  26. 11 Jun, 2020 1 commit
    • Philip Meier's avatar
      Add convert_image_dtype to functionals (#2078) · c2e8a008
      Philip Meier authored
      
      
      * add convert_image_dtype to functionals
      
      * add ConvertImageDtype transform
      
      * add test
      
      * remove underscores from numbers since they are not compatible with python<3.6
      
      * address review comments 1/3
      
      * fix torch.bool
      
      * use torch.iinfo in test
      
      * fix flake8
      
      * remove double conversion
      
      * fix flake9
      
      * bug fix
      
      * add error messages to test
      
      * disable torch.float16 and torch.half for now
      
      * add docstring
      
      * add test for consistency
      
      * move nested function to top
      
      * test in CI
      
      * dirty progress
      
      * add int to int and cleanup
      
      * lint
      Co-authored-by: default avatarPhilip Meier <meier.philip@posteo.de>
      c2e8a008
  27. 04 Jun, 2020 1 commit
  28. 18 May, 2020 1 commit
    • 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
  29. 14 Apr, 2020 1 commit
  30. 03 Apr, 2020 1 commit
  31. 31 Mar, 2020 1 commit
  32. 23 Mar, 2020 2 commits
  33. 29 Jan, 2020 1 commit
  34. 22 Jan, 2020 1 commit
    • Philip Meier's avatar
      Fix fill in rotate (#1760) · 8f4f8d89
      Philip Meier authored
      * initial fix
      
      * outsourced num bands lookup
      
      * fix doc
      
      * added pillow version requirement
      
      * simplify number of bands extraction
      
      * remove unrelated change
      
      * remove indirect dependency on pillow>=5.2.0
      
      * extend docstring to transform
      
      * bug fix
      
      * added test
      8f4f8d89
  35. 10 Jan, 2020 1 commit
  36. 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