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

export_onnx_test.py 882 B

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
  1. import tempfile
  2. import unittest
  3. from super_gradients.common.object_names import Models
  4. from super_gradients.training import models
  5. from torchvision.transforms import Compose, Normalize, Resize
  6. from super_gradients.training.transforms import Standardize
  7. import os
  8. class TestModelsONNXExport(unittest.TestCase):
  9. def test_models_onnx_export(self):
  10. pretrained_model = models.get(Models.RESNET18, num_classes=1000, pretrained_weights="imagenet")
  11. preprocess = Compose([Resize(224), Standardize(), Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])])
  12. with tempfile.TemporaryDirectory() as tmpdirname:
  13. out_path = os.path.join(tmpdirname, "resnet18.onnx")
  14. models.convert_to_onnx(model=pretrained_model, out_path=out_path, input_shape=(3, 256, 256), pre_process=preprocess)
  15. if __name__ == "__main__":
  16. unittest.main()
Tip!

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

Comments

Loading...