A Visualizer for PyTorch Image Transformations

Tldr; Check out the app here.

Image augmentation is a common technique used when training computer vision models in order to generate artificial training data by transforming in your actual training data, for example, random rotations and shifts.


This content originally appeared on DEV Community and was authored by Mage

Alt Text

Alt Text

Tldr; Check out the app here.

Image augmentation is a common technique used when training computer vision models in order to generate artificial training data by transforming in your actual training data, for example, random rotations and shifts.

Alt TextWe created 4 new images of cats!

However these augmentations can often be a source of subtle bugs. For example here is an typical PyTorch transform pipeline:

from torchvision import transforms

transform = transforms.Compose([
    transforms.RandomAffine(degrees=360, translate=(0.64, 0.98), scale=(0.81, 2.85), shear=(0.1, 0.5), fill=0, interpolation=InterpolationMode.NEAREST),
    transforms.ColorJitter(brightness=0.62, contrast=0.3, saturation=0.44, hue=0.24),
    transforms.RandomVerticalFlip(p=0.45)
])

Do you see anything obviously wrong with it?

Well, let’s see what happens when we actually try to apply these transformations to our cat.

Alt TextHalf of these don’t even look like cats!

As you can see the transformations were not properly tuned and resulted in a significant number of images being completely unrecognizable. If we train the model on this augmented dataset, it’s no longer learning what a cat looks like.
These sorts of bugs are tricky because no errors will be raised. Instead the result would be that the model will not perform as well on the un-augmented test dataset as it could have.

Introducing a PyTorch transforms visualizer

Alt Text

You can use this tool to develop and sanity check your transforms on actual images before using them in a training script. It supports all the transforms provided in the torchvision.transforms package.

Check it out here!


This content originally appeared on DEV Community and was authored by Mage


Print Share Comment Cite Upload Translate Updates
APA

Mage | Sciencx (2021-09-14T18:38:45+00:00) A Visualizer for PyTorch Image Transformations. Retrieved from https://www.scien.cx/2021/09/14/a-visualizer-for-pytorch-image-transformations/

MLA
" » A Visualizer for PyTorch Image Transformations." Mage | Sciencx - Tuesday September 14, 2021, https://www.scien.cx/2021/09/14/a-visualizer-for-pytorch-image-transformations/
HARVARD
Mage | Sciencx Tuesday September 14, 2021 » A Visualizer for PyTorch Image Transformations., viewed ,<https://www.scien.cx/2021/09/14/a-visualizer-for-pytorch-image-transformations/>
VANCOUVER
Mage | Sciencx - » A Visualizer for PyTorch Image Transformations. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/09/14/a-visualizer-for-pytorch-image-transformations/
CHICAGO
" » A Visualizer for PyTorch Image Transformations." Mage | Sciencx - Accessed . https://www.scien.cx/2021/09/14/a-visualizer-for-pytorch-image-transformations/
IEEE
" » A Visualizer for PyTorch Image Transformations." Mage | Sciencx [Online]. Available: https://www.scien.cx/2021/09/14/a-visualizer-for-pytorch-image-transformations/. [Accessed: ]
rf:citation
» A Visualizer for PyTorch Image Transformations | Mage | Sciencx | https://www.scien.cx/2021/09/14/a-visualizer-for-pytorch-image-transformations/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.