Skip to content

Commit

Permalink
Stricter tests for serializations
Browse files Browse the repository at this point in the history
  • Loading branch information
ternaus committed Mar 9, 2024
1 parent f744c83 commit 1a27bc4
Showing 1 changed file with 32 additions and 19 deletions.
51 changes: 32 additions & 19 deletions tests/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,20 @@
"border_mode": 0,
"value": [124, 116, 104],
"position": "top_left"
}
},
A.GlassBlur:dict(sigma=0.8, max_delta=5, iterations=3, mode="exact"),
A.GridDropout: dict(
ratio=0.75,
unit_size_min=2,
unit_size_max=10,
shift_x=10,
shift_y=20,
random_offset=True,
fill_value=10,
mask_fill_value=20,
)
},
except_augmentations={
A.RandomCropNearBBox,
A.RandomSizedBBoxSafeCrop,
A.BBoxSafeRandomCrop,
A.FDA,
A.HistogramMatching,
A.PixelDistributionAdaptation,
Expand Down Expand Up @@ -418,7 +426,21 @@ def test_augmentations_serialization(augmentation_cls, params, p, seed, image, m
"border_mode": 0,
"value": [124, 116, 104],
"position": "top_left"
}]
}],
[A.GlassBlur, dict(sigma=0.8, max_delta=5, iterations=3, mode="exact")],
[
A.GridDropout,
dict(
ratio=0.75,
unit_size_min=2,
unit_size_max=10,
shift_x=10,
shift_y=20,
random_offset=True,
fill_value=10,
mask_fill_value=20,
)
],
]

AUGMENTATION_CLS_EXCEPT = {
Expand All @@ -429,8 +451,6 @@ def test_augmentations_serialization(augmentation_cls, params, p, seed, image, m
A.RandomCropNearBBox,
A.RandomSizedBBoxSafeCrop,
A.BBoxSafeRandomCrop,
A.GridDropout,
A.GlassBlur,
A.TemplateTransform,
A.MixUp
}
Expand Down Expand Up @@ -487,7 +507,6 @@ def test_augmentations_serialization_to_file_with_custom_parameters(
custom_arguments={
A.Crop: {"y_min": 0, "y_max": 10, "x_min": 0, "x_max": 10},
A.CenterCrop: {"height": 10, "width": 10},
A.CropNonEmptyMaskIfExists: {"height": 10, "width": 10},
A.RandomCrop: {"height": 10, "width": 10},
A.RandomResizedCrop: {"height": 10, "width": 10},
A.RandomSizedCrop: {"min_max_height": (4, 8), "height": 10, "width": 10},
Expand All @@ -501,25 +520,22 @@ def test_augmentations_serialization_to_file_with_custom_parameters(
"border_mode": 0,
"value": [124, 116, 104],
"position": "top_left"
}
},
},
except_augmentations={
A.RandomCropNearBBox,
A.FDA,
A.HistogramMatching,
A.PixelDistributionAdaptation,
A.Lambda,
A.CoarseDropout,
A.CropNonEmptyMaskIfExists,
A.ElasticTransform,
A.GridDistortion,
A.RandomGridShuffle,
A.GridDropout,
A.MaskDropout,
A.OpticalDistortion,
A.TemplateTransform,
A.XYMasking,
A.MixUp
A.MixUp,
A.CropNonEmptyMaskIfExists,
A.GridDropout
},
),
)
Expand Down Expand Up @@ -569,16 +585,13 @@ def test_augmentations_for_bboxes_serialization(
}
},
except_augmentations={
A.RandomCropNearBBox,
A.FDA,
A.HistogramMatching,
A.PixelDistributionAdaptation,
A.Lambda,
A.CoarseDropout,
A.CropNonEmptyMaskIfExists,
A.ElasticTransform,
A.GridDistortion,
A.RandomGridShuffle,
A.GridDropout,
A.MaskDropout,
A.OpticalDistortion,
Expand Down Expand Up @@ -1023,7 +1036,7 @@ def test_template_transform_serialization(image, template, seed, p):
A.TemplateTransform,
A.MixUp,
A.ShiftScaleRotate,
},) )
}) )
def test_augmentations_serialization(augmentation_cls, params):
instance = augmentation_cls(**params)

Expand Down

0 comments on commit 1a27bc4

Please sign in to comment.