test_loading.py 832 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (c) OpenMMLab. All rights reserved.
  2. from unittest import TestCase
  3. import numpy as np
  4. from mmcv import imread
  5. from mmpose.datasets.transforms.loading import LoadImage
  6. class TestLoadImage(TestCase):
  7. def test_load_image(self):
  8. transform = LoadImage()
  9. results = dict(img_path='tests/data/coco/000000000785.jpg')
  10. results = transform(results)
  11. self.assertIsInstance(results['img'], np.ndarray)
  12. def test_with_input_image(self):
  13. transform = LoadImage(to_float32=True)
  14. img_path = 'tests/data/coco/000000000785.jpg'
  15. results = dict(
  16. img_path=img_path, img=imread(img_path).astype(np.uint8))
  17. results = transform(results)
  18. self.assertIsInstance(results['img'], np.ndarray)
  19. self.assertTrue(results['img'].dtype, np.float32)