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

yolo_nas_integration_test.py 2.5 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
48
49
50
51
52
  1. import os
  2. import unittest
  3. from super_gradients.training import models
  4. from super_gradients.training.dataloaders import coco2017_val_yolo_nas
  5. from super_gradients.training import Trainer
  6. from super_gradients.training.metrics import DetectionMetrics
  7. from super_gradients.training.models.detection_models.pp_yolo_e import PPYoloEPostPredictionCallback
  8. class YoloNASIntegrationTest(unittest.TestCase):
  9. def setUp(self):
  10. self.data_dir = os.environ.get("SUPER_GRADIENTS_COCO_DATASET_DIR", "/data/coco")
  11. def test_yolo_nas_s_coco(self):
  12. trainer = Trainer("test_yolo_nas_s")
  13. model = models.get("yolo_nas_s", num_classes=80, pretrained_weights="coco")
  14. dl = coco2017_val_yolo_nas(dataset_params=dict(data_dir=self.data_dir))
  15. metric = DetectionMetrics(
  16. normalize_targets=True,
  17. post_prediction_callback=PPYoloEPostPredictionCallback(score_threshold=0.03, nms_top_k=1000, max_predictions=300, nms_threshold=0.65),
  18. num_cls=80,
  19. )
  20. metric_values = trainer.test(model=model, test_loader=dl, test_metrics_list=[metric])
  21. self.assertAlmostEqual(metric_values[metric.map_str], 0.475, delta=0.001)
  22. def test_yolo_nas_m_coco(self):
  23. trainer = Trainer("test_yolo_nas_m")
  24. model = models.get("yolo_nas_m", num_classes=80, pretrained_weights="coco")
  25. dl = coco2017_val_yolo_nas(dataset_params=dict(data_dir=self.data_dir))
  26. metric = DetectionMetrics(
  27. normalize_targets=True,
  28. post_prediction_callback=PPYoloEPostPredictionCallback(score_threshold=0.03, nms_top_k=1000, max_predictions=300, nms_threshold=0.65),
  29. num_cls=80,
  30. )
  31. metric_values = trainer.test(model=model, test_loader=dl, test_metrics_list=[metric])
  32. self.assertAlmostEqual(metric_values[metric.map_str], 0.5155, delta=0.001)
  33. def test_yolo_nas_l_coco(self):
  34. trainer = Trainer("test_yolo_nas_l")
  35. model = models.get("yolo_nas_l", num_classes=80, pretrained_weights="coco")
  36. dl = coco2017_val_yolo_nas(dataset_params=dict(data_dir=self.data_dir))
  37. metric = DetectionMetrics(
  38. normalize_targets=True,
  39. post_prediction_callback=PPYoloEPostPredictionCallback(score_threshold=0.03, nms_top_k=1000, max_predictions=300, nms_threshold=0.65),
  40. num_cls=80,
  41. )
  42. metric_values = trainer.test(model=model, test_loader=dl, test_metrics_list=[metric])
  43. self.assertAlmostEqual(metric_values[metric.map_str], 0.5222, delta=0.001)
  44. if __name__ == "__main__":
  45. unittest.main()
Tip!

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

Comments

Loading...