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

#587 Feature/sg 521 gpu tests

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:feature/SG-521_gpu_tests
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
  1. import unittest
  2. import shutil
  3. from coverage.annotate import os
  4. from super_gradients.common.environment import environment_config
  5. import torch
  6. class ShortenedRecipesAccuracyTests(unittest.TestCase):
  7. @classmethod
  8. def setUp(cls):
  9. cls.experiment_names = ["shortened_cifar10_resnet_accuracy_test", "shortened_coco2017_yolox_n_map_test", "shortened_cityscapes_regseg48_iou_test"]
  10. def test_shortened_cifar10_resnet_accuracy(self):
  11. self.assertTrue(self._reached_goal_metric(experiment_name="shortened_cifar10_resnet_accuracy_test", metric_value=0.9167, delta=0.05))
  12. def test_shortened_coco2017_yolox_n_map(self):
  13. self.assertTrue(self._reached_goal_metric(experiment_name="shortened_coco2017_yolox_n_map_test", metric_value=0.044, delta=0.02))
  14. def test_shortened_cityscapes_regseg48_iou(self):
  15. self.assertTrue(self._reached_goal_metric(experiment_name="shortened_cityscapes_regseg48_iou_test", metric_value=0.263, delta=0.05))
  16. @classmethod
  17. def _reached_goal_metric(cls, experiment_name: str, metric_value: float, delta: float):
  18. ckpt_dir = os.path.join(environment_config.PKG_CHECKPOINTS_DIR, experiment_name)
  19. sd = torch.load(os.path.join(ckpt_dir, "ckpt_best.pth"))
  20. metric_val_reached = sd["acc"].cpu().item()
  21. diff = abs(metric_val_reached - metric_value)
  22. print(
  23. "Goal metric value: " + str(metric_value) + ", metric value reached: " + str(metric_val_reached) + ",diff: " + str(diff) + ", delta: " + str(delta)
  24. )
  25. return diff <= delta
  26. @classmethod
  27. def tearDownClass(cls) -> None:
  28. # ERASE ALL THE FOLDERS THAT WERE CREATED DURING THIS TEST
  29. for folder in cls.experiment_names:
  30. ckpt_dir = os.path.join(environment_config.PKG_CHECKPOINTS_DIR, folder)
  31. if os.path.isdir(ckpt_dir):
  32. shutil.rmtree(ckpt_dir)
  33. if __name__ == "__main__":
  34. unittest.main()
Discard
Tip!

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