Files
onnxruntime_go/test_data/modify_metadata.py
yalue ed34aa7356 Add GetModelMetadata API
- Added functionality to wrap the onnxruntime SessionGetModelMetadata
   for both AdvancedSession types and plain .onnx files.
2024-02-01 20:59:02 -05:00

21 lines
673 B
Python

# This file is used to modify the metadata of example_big_compute.onnx for the
# sake of testing. The choice of example_big_compute.onnx was arbitrary.
import onnx
def main():
file_path = "example_big_compute.onnx"
model = onnx.load(file_path)
model.doc_string = "This is a test description."
model.model_version = 1337
model.domain = "test domain"
custom_1 = model.metadata_props.add()
custom_1.key = "test key 1"
custom_1.value = ""
custom_2 = model.metadata_props.add()
custom_2.key = "test key 2"
custom_2.value = "Test key 2 value"
onnx.save(model, file_path)
if __name__ == "__main__":
main()