Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

pose_estimation_dataset_test.py 1.8 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  1. import os.path
  2. import unittest
  3. import numpy as np
  4. import torch
  5. from super_gradients.common.object_names import Models
  6. from super_gradients.module_interfaces import HasPredict
  7. from super_gradients.training import models
  8. from super_gradients.training.dataloaders import coco2017_pose_val
  9. from super_gradients.training.datasets.pose_estimation_datasets import DEKRTargetsGenerator
  10. class TestPoseEstimationDataset(unittest.TestCase):
  11. def test_dekr_target_generator(self):
  12. target_generator = DEKRTargetsGenerator(
  13. output_stride=4,
  14. sigma=2,
  15. center_sigma=4,
  16. bg_weight=0.1,
  17. offset_radius=4,
  18. )
  19. joints = np.random.randint(0, 255, (4, 17, 3))
  20. joints[:, :, 2] = 1
  21. heatmaps, mask, offset_map, offset_weight = target_generator(
  22. image=torch.zeros((3, 256, 256)),
  23. joints=joints,
  24. mask=np.ones((256, 256)),
  25. )
  26. self.assertEqual(heatmaps.shape, (18, 64, 64))
  27. self.assertEqual(mask.shape, (18, 64, 64))
  28. self.assertEqual(offset_map.shape, (34, 64, 64))
  29. self.assertEqual(offset_weight.shape, (34, 64, 64))
  30. def test_get_dataset_preprocessing_params(self):
  31. data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data", "coco2017")
  32. loader = coco2017_pose_val(dataset_params={"target_generator": None, "data_dir": data_dir, "json_file": "annotations/person_keypoints_val2017.json"})
  33. preprocessing_params = loader.dataset.get_dataset_preprocessing_params()
  34. self.assertIsNotNone(preprocessing_params)
  35. dekr: HasPredict = models.get(Models.DEKR_W32_NO_DC, pretrained_weights="coco_pose")
  36. dekr.set_dataset_processing_params(**preprocessing_params)
  37. dekr.predict(np.zeros((640, 640, 3), dtype=np.uint8))
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...