-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Unify Tensor and PIL transforms #2292
Comments
Hi! I would be glad to work on a PR for this issue. I can start with the color jitter if that's okay with you |
@fmassa I can work on some of these listed transformation if it is OK. |
In the documentation of pytorch it is mentioned that functional module works with both tensors and pil objects. This is about torch version 1.5.1 and torchvision 0.6.1. However, when I try to use them with torch.tensor it throws an error that the object is not PIL. I checked the source code and the snippet shown in the docs is missing. I use the functional.hflip() function of the docs. I thought that the unification has been completed, hasn't it? |
@dimimal the unification is not yet complete Can you point out where in the documentation you found the reference that all functions work with both tensors and PIL Images? |
@vfdev-5 sure go for it! |
@fmassa I wasn't using the master and the docs confused me with the noted version. Thank you. Is there anything I can do to help in contribution? |
@dimimal sure, contributions are more than welcome! There are two steps here: finishing up #1375 , and then implementing the glue code, similarly to the example PRs #2282 #2283, or more recently #2345 I think implementing Note that one of the biggest difficulties will be making the implementation work with torchscript, as not everything that we use is natively supported. |
- RandomErasing is not scriptable
* Related to #2292 - RandomErasing is not scriptable * Fixed code according to review comments - added additional checking of value vs img num_channels
@fmassa if ops should also work on tensors on non-cpu devices, a supplementary check of certain geometrical ops will be needed. Should we setup some CI tests for that ? |
Yes, please! |
* Related to pytorch#2292 - RandomErasing is not scriptable * Fixed code according to review comments - added additional checking of value vs img num_channels
@nairbv would you be interested in working on unifying |
@vfdev-5 go for it! |
The issue can be closed as all mentioned transformations now support tensor and pil image as input. |
Hi! Very exciting codes! Wondering whether future commits will support fill color other than 0 for tensor affine transformations? It is kind of important for tasks like semantic segmentation when transforming labels. @vfdev-5 |
@voldemortX thanks for the feedback !
Could you please open an issue for that such we could track this feature request and see what could be possible to do.
|
New issue opened #2887 |
Now that most of the tensor transforms have been implemented #1375, it is time to make unify the implementations for PIL and Tensor so that
torchvision.transforms
andtorchvision.transforms.functional
works seamlessly between both datatypes.As such, we would like that the following work with the same interface:
Example PRs adding support for
hflip
andvflip
: #2282 #2283We would like to add support for torchscript to the
torchvision.transforms
interface as well, which for simplicity might require a few changes. Most notably we would need the transforms to inherit fromnn.Module
.Here is a list of transforms that can be readily converted:
F.rotate
#2495 Unified inputs forT.RandomRotation
#2496 Fixes F.affine and F.rotate to support rectangular tensor images #2553)T.RandomAffine
transformation (2292) #2478, Fixes F.affine and F.rotate to support rectangular tensor images #2553)The text was updated successfully, but these errors were encountered: