test_openimages.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright (c) OpenMMLab. All rights reserved.
  2. import unittest
  3. from mmdet.datasets import OpenImagesChallengeDataset, OpenImagesDataset
  4. class TestOpenImagesDataset(unittest.TestCase):
  5. def test_init(self):
  6. dataset = OpenImagesDataset(
  7. data_root='tests/data/OpenImages/',
  8. ann_file='annotations/oidv6-train-annotations-bbox.csv',
  9. data_prefix=dict(img='OpenImages/train/'),
  10. label_file='annotations/class-descriptions-boxable.csv',
  11. hierarchy_file='annotations/bbox_labels_600_hierarchy.json',
  12. meta_file='annotations/image-metas.pkl',
  13. pipeline=[])
  14. dataset.full_init()
  15. self.assertEqual(len(dataset), 1)
  16. self.assertEqual(dataset.metainfo['classes'], ['Airplane'])
  17. class TestOpenImagesChallengeDataset(unittest.TestCase):
  18. def test_init(self):
  19. dataset = OpenImagesChallengeDataset(
  20. data_root='tests/data/OpenImages/',
  21. ann_file='challenge2019/challenge-2019-train-detection-bbox.txt',
  22. data_prefix=dict(img='OpenImages/train/'),
  23. label_file='challenge2019/cls-label-description.csv',
  24. hierarchy_file='challenge2019/class_label_tree.np',
  25. meta_file='annotations/image-metas.pkl',
  26. pipeline=[])
  27. dataset.full_init()
  28. self.assertEqual(len(dataset), 1)
  29. self.assertEqual(dataset.metainfo['classes'], ['Airplane'])