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

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

Comments

Loading...