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

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

Comments

Loading...