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

#367 fix: Request correct hydra-core

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:hotfix/ALG-000_hydra-req
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
  1. import os
  2. import unittest
  3. from super_gradients.training import Trainer, utils as core_utils, models
  4. from super_gradients.training.dataloaders.dataloaders import coco2017_val
  5. from super_gradients.training.datasets.datasets_conf import COCO_DETECTION_CLASSES_LIST
  6. from super_gradients.training.models.detection_models.yolo_base import YoloPostPredictionCallback
  7. from super_gradients.training.utils.detection_utils import DetectionVisualization
  8. class TestDetectionUtils(unittest.TestCase):
  9. def test_visualization(self):
  10. # Create Yolo model
  11. trainer = Trainer('visualization_test',
  12. model_checkpoints_location='local',
  13. post_prediction_callback=YoloPostPredictionCallback())
  14. model = models.get("yolox_n", pretrained_weights="coco")
  15. # Simulate one iteration of validation subset
  16. valid_loader = coco2017_val()
  17. batch_i, (imgs, targets) = 0, next(iter(valid_loader))
  18. imgs = core_utils.tensor_container_to_device(imgs, trainer.device)
  19. targets = core_utils.tensor_container_to_device(targets, trainer.device)
  20. output = model(imgs)
  21. output = trainer.post_prediction_callback(output)
  22. # Visualize the batch
  23. DetectionVisualization.visualize_batch(imgs, output, targets, batch_i,
  24. COCO_DETECTION_CLASSES_LIST, trainer.checkpoints_dir_path)
  25. # Assert images ware created and delete them
  26. img_name = '{}/{}_{}.jpg'
  27. for i in range(4):
  28. img_path = img_name.format(trainer.checkpoints_dir_path, batch_i, i)
  29. self.assertTrue(os.path.exists(img_path))
  30. os.remove(img_path)
  31. if __name__ == '__main__':
  32. unittest.main()
Discard
Tip!

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