Skip to content

Instantly share code, notes, and snippets.

@bernhardschaefer
Created October 19, 2022 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bernhardschaefer/1ad797e12fc34bf988495aa1d0ce0779 to your computer and use it in GitHub Desktop.
Save bernhardschaefer/1ad797e12fc34bf988495aa1d0ce0779 to your computer and use it in GitHub Desktop.
Albumentations Augmenation Pipeline
from albumentations import *
transforms = [
OneOf([
LongestMaxSize(p=0.7, max_size=1333),
RandomResizedCrop(
p=0.3, height=1333, width=1333,
scale=(0.2, 1.0), ratio=(0.5, 2.0)
),
], p=1.0),
RandomRotate90(p=0.3),
HorizontalFlip(p=0.3),
VerticalFlip(p=0.3),
ShiftScaleRotate(
p=0.3, shift_limit=0.03, scale_limit=(-0.2, 0.0), rotate_limit=5,
border_mode=cv2.BORDER_CONSTANT, value=(255, 255, 255)
),
GaussNoise(p=0.3),
OneOf([CLAHE(), Sharpen(), RandomBrightnessContrast()], p=0.3),
HueSaturationValue(p=0.3, val_shift_limit=0),
]
aug = Compose(
transforms=transforms,
bbox_params=BboxParams("coco", min_area=10.0, min_visibility=0.7),
keypoint_params=KeypointParams(format="xy")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment