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

deci_yolo_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
49
50
51
52
53
54
  1. import unittest
  2. from super_gradients.training import models
  3. from super_gradients.training.dataloaders import coco2017_val_deci_yolo
  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 DeciYoloTest(unittest.TestCase):
  8. def test_deciyolo_s_coco(self):
  9. trainer = Trainer("test_deci_yolo_s")
  10. model = models.get("deciyolo_s", num_classes=80, pretrained_weights="coco")
  11. dl = coco2017_val_deci_yolo()
  12. metrics = [
  13. DetectionMetrics(
  14. normalize_targets=True,
  15. post_prediction_callback=PPYoloEPostPredictionCallback(score_threshold=0.03, nms_top_k=1000, max_predictions=300, nms_threshold=0.65),
  16. num_cls=80,
  17. )
  18. ]
  19. map_result = trainer.test(model=model, test_loader=dl, test_metrics_list=metrics)[2]
  20. self.assertAlmostEqual(map_result, 0.475, delta=0.001)
  21. def test_deciyolo_m_coco(self):
  22. trainer = Trainer("test_deci_yolo_m")
  23. model = models.get("deciyolo_m", num_classes=80, pretrained_weights="coco")
  24. dl = coco2017_val_deci_yolo()
  25. metrics = [
  26. 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. ]
  32. map_result = trainer.test(model=model, test_loader=dl, test_metrics_list=metrics)[2]
  33. self.assertAlmostEqual(map_result, 0.5155, delta=0.001)
  34. def test_deciyolo_l_coco(self):
  35. trainer = Trainer("test_deci_yolo_l")
  36. model = models.get("deciyolo_l", num_classes=80, pretrained_weights="coco")
  37. dl = coco2017_val_deci_yolo()
  38. metrics = [
  39. DetectionMetrics(
  40. normalize_targets=True,
  41. post_prediction_callback=PPYoloEPostPredictionCallback(score_threshold=0.03, nms_top_k=1000, max_predictions=300, nms_threshold=0.65),
  42. num_cls=80,
  43. )
  44. ]
  45. map_result = trainer.test(model=model, test_loader=dl, test_metrics_list=metrics)[2]
  46. self.assertAlmostEqual(map_result, 0.5222, delta=0.001)
  47. if __name__ == "__main__":
  48. unittest.main()
Tip!

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

Comments

Loading...