From 4421f5149456ed5fe429922d28b9b94305c1a55d Mon Sep 17 00:00:00 2001 From: ckkelvinchan Date: Wed, 14 Apr 2021 08:48:57 +0800 Subject: [PATCH] rename to 'MirrorSequence' --- mmedit/datasets/pipelines/__init__.py | 9 ++++----- mmedit/datasets/pipelines/augmentation.py | 2 +- tests/test_augmentation.py | 15 +++++++-------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/mmedit/datasets/pipelines/__init__.py b/mmedit/datasets/pipelines/__init__.py index 8b9f76ce3f..b337dd1b40 100644 --- a/mmedit/datasets/pipelines/__init__.py +++ b/mmedit/datasets/pipelines/__init__.py @@ -1,8 +1,7 @@ from .augmentation import (BinarizeImage, Flip, GenerateFrameIndices, - GenerateFrameIndiceswithPadding, - MirrorSequenceExtend, Pad, RandomAffine, - RandomJitter, RandomMaskDilation, RandomTransposeHW, - Resize, TemporalReverse) + GenerateFrameIndiceswithPadding, MirrorSequence, + Pad, RandomAffine, RandomJitter, RandomMaskDilation, + RandomTransposeHW, Resize, TemporalReverse) from .compose import Compose from .crop import (Crop, CropAroundCenter, CropAroundFg, CropAroundUnknown, FixedCrop, ModCrop, PairedRandomCrop) @@ -30,5 +29,5 @@ 'LoadPairedImageFromFile', 'GenerateSoftSeg', 'GenerateSeg', 'PerturbBg', 'CropAroundFg', 'GetSpatialDiscountMask', 'RandomDownSampling', 'GenerateTrimapWithDistTransform', 'TransformTrimap', - 'GenerateCoordinateAndCell', 'MirrorSequenceExtend' + 'GenerateCoordinateAndCell', 'MirrorSequence' ] diff --git a/mmedit/datasets/pipelines/augmentation.py b/mmedit/datasets/pipelines/augmentation.py index 592622ba5d..2b76c444cb 100644 --- a/mmedit/datasets/pipelines/augmentation.py +++ b/mmedit/datasets/pipelines/augmentation.py @@ -898,7 +898,7 @@ def __repr__(self): @PIPELINES.register_module() -class MirrorSequenceExtend: +class MirrorSequence: """Extend short sequences (e.g. Vimeo-90K) by mirroring the sequences Given a sequence with N frames (x1, ..., xN), extend the sequence to diff --git a/tests/test_augmentation.py b/tests/test_augmentation.py index 4df47bade0..a2452cbe5b 100644 --- a/tests/test_augmentation.py +++ b/tests/test_augmentation.py @@ -8,7 +8,7 @@ from mmedit.datasets.pipelines import (BinarizeImage, Flip, GenerateFrameIndices, GenerateFrameIndiceswithPadding, - MirrorSequenceExtend, Pad, RandomAffine, + MirrorSequence, Pad, RandomAffine, RandomJitter, RandomMaskDilation, RandomTransposeHW, Resize, TemporalReverse) @@ -624,14 +624,14 @@ def test_temporal_reverse(self): np.testing.assert_almost_equal(results['lq'][1], img_lq2) np.testing.assert_almost_equal(results['gt'][0], img_gt) - def mirror_sequence_extend(self): + def mirror_sequence(self): lqs = [np.random.rand(4, 4, 3) for _ in range(0, 5)] gts = [np.random.rand(16, 16, 3) for _ in range(0, 5)] target_keys = ['lq', 'gt'] - mirror_sequence_extend = MirrorSequenceExtend(keys=['lq', 'gt']) + mirror_sequence = MirrorSequence(keys=['lq', 'gt']) results = dict(lq=lqs, gt=gts) - results = mirror_sequence_extend(results) + results = mirror_sequence(results) assert self.check_keys_contain(results.keys(), target_keys) for i in range(0, 5): @@ -640,11 +640,10 @@ def mirror_sequence_extend(self): np.testing.assert_almost_equal(results['gt'][i], results['gt'][-i - 1]) - assert repr(mirror_sequence_extend - ) == mirror_sequence_extend.__class__.__name__ + ( - f"(keys=['lq', 'gt'])") + assert repr(mirror_sequence) == mirror_sequence.__class__.__name__ + ( + f"(keys=['lq', 'gt'])") # each key should contain a list of nparray with pytest.raises(TypeError): results = dict(lq=0, gt=gts) - mirror_sequence_extend(results) + mirror_sequence(results)