A library which turns torchvision transformations invertible and replayable.
Project description
invertransforms
A library which turns torchvision transformations invertible and replayable.
Installation
pip install invertransforms
Usage
Simply replace previous torchvision import statements and enjoy the addons.
# from torchvision import transforms as T
import invertransforms as T
transform = T.Compose([
T.RandomCrop(size=256),
T.ToTensor(),
])
img_tensor = transform(img)
# invert
img_again = transform.invert(img_tensor)
# replay
img_tensor2 = transform.replay(img2)
All transformations have an inverse
transformation attached to it.
inv_transform = transform.inverse()
img_inv = inv_transform(img)
Notes:
If a transformation is random, it is necessary to apply it once before calling invert
or inverse()
. Otherwise it will raise InvertibleError
.
On the otherhand, replay
can be called before, it will simply set the randomness on its first call.
Use Case
This library can be particularly useful in following situations:
- Reverting your model outputs in order to stack predictions
- Applying the same transformations on two different images
- blah-blah
Features
- Invert any transformations even random ones
- Replay any transformations even random ones
- All classes extends its torchvision transformation equivalent class
- Extensive unit testing
- blah-blah
Documentation
The above features are explained in more detail in invertransforms' documentation.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.