本文整理汇总了Python中albumentations.RandomRotate90方法的典型用法代码示例。如果您正苦于以下问题:Python albumentations.RandomRotate90方法的具体用法?Python albumentations.RandomRotate90怎么用?Python albumentations.RandomRotate90使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类albumentations
的用法示例。
在下文中一共展示了albumentations.RandomRotate90方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import albumentations [as 别名]
# 或者: from albumentations import RandomRotate90 [as 别名]
def __init__(
self,
input_key: str = "image",
output_key: str = "rotation_factor",
targets_key: str = None,
rotate_probability: float = 1.0,
hflip_probability: float = 0.5,
one_hot_classes: int = None,
):
"""
Args:
input_key (str): input key to use from annotation dict
output_key (str): output key to use to store the result
"""
self.input_key = input_key
self.output_key = output_key
self.targets_key = targets_key
self.rotate_probability = rotate_probability
self.hflip_probability = hflip_probability
self.rotate = albu.RandomRotate90()
self.hflip = albu.HorizontalFlip()
self.one_hot_classes = (
one_hot_classes * 8 if one_hot_classes is not None else None
)
示例2: test_transform_pipeline_serialization_with_bboxes
# 需要导入模块: import albumentations [as 别名]
# 或者: from albumentations import RandomRotate90 [as 别名]
def test_transform_pipeline_serialization_with_bboxes(seed, image, bboxes, bbox_format, labels):
aug = A.Compose(
[
A.OneOrOther(
A.Compose([A.RandomRotate90(), A.OneOf([A.HorizontalFlip(p=0.5), A.VerticalFlip(p=0.5)])]),
A.Compose([A.Rotate(p=0.5), A.OneOf([A.HueSaturationValue(p=0.5), A.RGBShift(p=0.7)], p=1)]),
),
A.HorizontalFlip(p=1),
A.RandomBrightnessContrast(p=0.5),
],
bbox_params={"format": bbox_format, "label_fields": ["labels"]},
)
serialized_aug = A.to_dict(aug)
deserialized_aug = A.from_dict(serialized_aug)
set_seed(seed)
aug_data = aug(image=image, bboxes=bboxes, labels=labels)
set_seed(seed)
deserialized_aug_data = deserialized_aug(image=image, bboxes=bboxes, labels=labels)
assert np.array_equal(aug_data["image"], deserialized_aug_data["image"])
assert np.array_equal(aug_data["bboxes"], deserialized_aug_data["bboxes"])
示例3: test_transform_pipeline_serialization_with_keypoints
# 需要导入模块: import albumentations [as 别名]
# 或者: from albumentations import RandomRotate90 [as 别名]
def test_transform_pipeline_serialization_with_keypoints(seed, image, keypoints, keypoint_format, labels):
aug = A.Compose(
[
A.OneOrOther(
A.Compose([A.RandomRotate90(), A.OneOf([A.HorizontalFlip(p=0.5), A.VerticalFlip(p=0.5)])]),
A.Compose([A.Rotate(p=0.5), A.OneOf([A.HueSaturationValue(p=0.5), A.RGBShift(p=0.7)], p=1)]),
),
A.HorizontalFlip(p=1),
A.RandomBrightnessContrast(p=0.5),
],
keypoint_params={"format": keypoint_format, "label_fields": ["labels"]},
)
serialized_aug = A.to_dict(aug)
deserialized_aug = A.from_dict(serialized_aug)
set_seed(seed)
aug_data = aug(image=image, keypoints=keypoints, labels=labels)
set_seed(seed)
deserialized_aug_data = deserialized_aug(image=image, keypoints=keypoints, labels=labels)
assert np.array_equal(aug_data["image"], deserialized_aug_data["image"])
assert np.array_equal(aug_data["keypoints"], deserialized_aug_data["keypoints"])
示例4: __init__
# 需要导入模块: import albumentations [as 别名]
# 或者: from albumentations import RandomRotate90 [as 别名]
def __init__(self,
base_dir='../../data/apolloscape',
road_record_list=[{'road':'road02_seg','record':[22, 23, 24, 25, 26]}, {'road':'road03_seg', 'record':[7, 8, 9, 10, 11, 12]}],
split='train',
ignore_index=255,
debug=False):
self.debug = debug
self.base_dir = Path(base_dir)
self.ignore_index = ignore_index
self.split = split
self.img_paths = []
self.lbl_paths = []
for road_record in road_record_list:
self.road_dir = self.base_dir / Path(road_record['road'])
self.record_list = road_record['record']
for record in self.record_list:
img_paths_tmp = self.road_dir.glob(f'ColorImage/Record{record:03}/Camera 5/*.jpg')
lbl_paths_tmp = self.road_dir.glob(f'Label/Record{record:03}/Camera 5/*.png')
img_paths_basenames = {Path(img_path.name).stem for img_path in img_paths_tmp}
lbl_paths_basenames = {Path(lbl_path.name).stem.replace('_bin', '') for lbl_path in lbl_paths_tmp}
intersection_basenames = img_paths_basenames & lbl_paths_basenames
img_paths_intersection = [self.road_dir / Path(f'ColorImage/Record{record:03}/Camera 5/{intersection_basename}.jpg')
for intersection_basename in intersection_basenames]
lbl_paths_intersection = [self.road_dir / Path(f'Label/Record{record:03}/Camera 5/{intersection_basename}_bin.png')
for intersection_basename in intersection_basenames]
self.img_paths += img_paths_intersection
self.lbl_paths += lbl_paths_intersection
self.img_paths.sort()
self.lbl_paths.sort()
print(len(self.img_paths), len(self.lbl_paths))
assert len(self.img_paths) == len(self.lbl_paths)
self.resizer = albu.Resize(height=512, width=1024)
self.augmenter = albu.Compose([albu.HorizontalFlip(p=0.5),
# albu.RandomRotate90(p=0.5),
albu.Rotate(limit=10, p=0.5),
# albu.CLAHE(p=0.2),
# albu.RandomContrast(p=0.2),
# albu.RandomBrightness(p=0.2),
# albu.RandomGamma(p=0.2),
# albu.GaussNoise(p=0.2),
# albu.Cutout(p=0.2)
])
self.img_transformer = transforms.Compose([transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225])])
self.lbl_transformer = torch.LongTensor