mirror of
https://github.com/yalue/onnxruntime_go.git
synced 2025-09-27 03:35:58 +08:00

- Added functionality to wrap the onnxruntime SessionGetModelMetadata for both AdvancedSession types and plain .onnx files.
21 lines
673 B
Python
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()
|