From 6a22c428c2ed5041480392514f09f24b4fa2cb23 Mon Sep 17 00:00:00 2001 From: Kyungmin Lee <30465912+lkm2835@users.noreply.github.com> Date: Sat, 22 Jan 2022 19:13:34 +0900 Subject: [PATCH] [Fix] Improve MultiImageMixDataset unittests coverage (#1197) * Fix typo in usage example * original MultiImageMixDataset code in mmdet * Add MultiImageMixDataset unittests in test_dataset_wrapper * fix lint error * fix value name ann_file to ann_dir * modify retrieve_data_cfg (#1) * remove dynamic_scale & add palette * modify retrieve_data_cfg method * modify retrieve_data_cfg func * fix error * improve the unittests coverage * fix unittests error * Dataset (#2) * add cfg-options * Add unittest in test_build_dataset * add blank line * add blank line * add a blank line Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com> * [Fix] Add MultiImageMixDataset unittests Co-authored-by: Younghoon-Lee <72462227+Younghoon-Lee@users.noreply.github.com> Co-authored-by: MeowZheng Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com> --- tests/test_data/test_dataset.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/tests/test_data/test_dataset.py b/tests/test_data/test_dataset.py index 643db46045..168f13417e 100644 --- a/tests/test_data/test_dataset.py +++ b/tests/test_data/test_dataset.py @@ -105,8 +105,7 @@ def test_dataset_wrapper(): img_scale = (60, 60) pipeline = [ - # dict(type='Mosaic', img_scale=img_scale, pad_val=255), - # need to merge mosaic + dict(type='RandomMosaic', prob=1, img_scale=img_scale), dict(type='RandomFlip', prob=0.5), dict(type='Resize', img_scale=img_scale, keep_ratio=False), ] @@ -130,14 +129,8 @@ def test_dataset_wrapper(): classes=classes, palette=palette) len_a = 2 - cat_ids_list_a = [ - np.random.randint(0, 80, num).tolist() - for num in np.random.randint(1, 20, len_a) - ] - dataset_a.data_infos = MagicMock() - dataset_a.data_infos.__len__.return_value = len_a - dataset_a.get_cat_ids = MagicMock( - side_effect=lambda idx: cat_ids_list_a[idx]) + dataset_a.img_infos = MagicMock() + dataset_a.img_infos.__len__.return_value = len_a multi_image_mix_dataset = MultiImageMixDataset(dataset_a, pipeline) assert len(multi_image_mix_dataset) == len(dataset_a)