can you show me an example of using albumentations to augment images #2378
Replies: 1 comment 1 reply
-
@vgg4resnet you can't directly combine torch transforms and alb in the same compose. Albumentations documentations has examples for converting standard pytorch setups to use albumentations. You can also use alb.Compose and a custom wrapper that wraps the albumentations transforms in a torchvision compatible transform to combine both in the same pipeline. The main thing is that albumentations needs the image to be converted from PIL (or tensor) to numpy array, some examples do this by also changing the dataset to use opencv, or convert to numpy, but it can be done in the transform stack if you have custom ops. Then at some point it needs to be back to a torch tensor (or numpy array) before it's collated by the dataloader. You'll likely want to disable the prefetcher unless you are being very careful. |
Beta Was this translation helpful? Give feedback.
-
hi ,there ,can you show me an example of using third party albumentations to augment images or I review the code ,but I cant where can I start to insert the code , insert code where before the transforms.Compose like this place?
tfl += [
MaybeToTensor(),
transforms.Normalize(
mean=torch.tensor(mean),
std=torch.tensor(std),
),
]
Beta Was this translation helpful? Give feedback.
All reactions