test_wider_face.py 880 B

12345678910111213141516171819202122232425262728
  1. # Copyright (c) OpenMMLab. All rights reserved.
  2. import unittest
  3. import cv2
  4. import numpy as np
  5. from mmdet.datasets import WIDERFaceDataset
  6. class TestWIDERFaceDataset(unittest.TestCase):
  7. def setUp(self) -> None:
  8. img_path = 'tests/data/WIDERFace/WIDER_train/0--Parade/0_Parade_marchingband_1_5.jpg' # noqa: E501
  9. dummy_img = np.zeros((683, 1024, 3), dtype=np.uint8)
  10. cv2.imwrite(img_path, dummy_img)
  11. def test_wider_face_dataset(self):
  12. dataset = WIDERFaceDataset(
  13. data_root='tests/data/WIDERFace',
  14. ann_file='train.txt',
  15. data_prefix=dict(img='WIDER_train'),
  16. pipeline=[])
  17. dataset.full_init()
  18. self.assertEqual(len(dataset), 1)
  19. data_list = dataset.load_data_list()
  20. self.assertEqual(len(data_list), 1)
  21. self.assertEqual(len(data_list[0]['instances']), 10)