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

test_predict.py 2.1 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
  1. import os
  2. import unittest
  3. import tempfile
  4. from super_gradients.common.object_names import Models
  5. from super_gradients.training import models
  6. class TestModelPredict(unittest.TestCase):
  7. def setUp(self) -> None:
  8. rootdir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
  9. self.images = [
  10. os.path.join(rootdir, "documentation", "source", "images", "examples", "countryside.jpg"),
  11. os.path.join(rootdir, "documentation", "source", "images", "examples", "street_busy.jpg"),
  12. "https://deci-datasets-research.s3.amazonaws.com/image_samples/beatles-abbeyroad.jpg",
  13. ]
  14. def test_classification_models(self):
  15. with tempfile.TemporaryDirectory() as tmp_dirname:
  16. for model_name in {Models.RESNET18, Models.EFFICIENTNET_B0, Models.MOBILENET_V2, Models.REGNETY200}:
  17. model = models.get(model_name, pretrained_weights="imagenet")
  18. predictions = model.predict(self.images)
  19. predictions.show()
  20. predictions.save(output_folder=tmp_dirname)
  21. def test_pose_estimation_models(self):
  22. model = models.get(Models.DEKR_W32_NO_DC, pretrained_weights="coco_pose")
  23. with tempfile.TemporaryDirectory() as tmp_dirname:
  24. predictions = model.predict(self.images)
  25. predictions.show()
  26. predictions.save(output_folder=tmp_dirname)
  27. def test_detection_models(self):
  28. model = models.get(Models.YOLO_NAS_S, pretrained_weights="coco")
  29. with tempfile.TemporaryDirectory() as tmp_dirname:
  30. predictions = model.predict(self.images)
  31. predictions.show()
  32. predictions.save(output_folder=tmp_dirname)
  33. def test_segmentation_model(self):
  34. model = models.get(model_name=Models.PP_LITE_T_SEG75, arch_params={"use_aux_heads": False}, num_classes=19, pretrained_weights="cityscapes")
  35. with tempfile.TemporaryDirectory() as tmp_dirname:
  36. predictions = model.predict(self.images)
  37. predictions.show()
  38. predictions.save(output_folder=tmp_dirname)
  39. if __name__ == "__main__":
  40. unittest.main()
Tip!

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

Comments

Loading...