Skip to content

Instantly share code, notes, and snippets.

@Chris-hughes10
Created July 16, 2021 09:32
Show Gist options
  • Save Chris-hughes10/a79860ca33c049f7cbe6068ce79e62ee to your computer and use it in GitHub Desktop.
Save Chris-hughes10/a79860ca33c049f7cbe6068ce79e62ee to your computer and use it in GitHub Desktop.
Effdet-blog-transformations
import albumentations as A
from albumentations.pytorch.transforms import ToTensorV2
def get_train_transforms(target_img_size=512):
return A.Compose(
[
A.HorizontalFlip(p=0.5),
A.Resize(height=target_img_size, width=target_img_size, p=1),
A.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
ToTensorV2(p=1),
],
p=1.0,
bbox_params=A.BboxParams(
format="pascal_voc", min_area=0, min_visibility=0, label_fields=["labels"]
),
)
def get_valid_transforms(target_img_size=512):
return A.Compose(
[
A.Resize(height=target_img_size, width=target_img_size, p=1),
A.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
ToTensorV2(p=1),
],
p=1.0,
bbox_params=A.BboxParams(
format="pascal_voc", min_area=0, min_visibility=0, label_fields=["labels"]
),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment