Skip to content

Instantly share code, notes, and snippets.

@CESARDELATORRE
Last active July 8, 2018 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CESARDELATORRE/080f9a9e89bff1f9634f281f97729cab to your computer and use it in GitHub Desktop.
Save CESARDELATORRE/080f9a9e89bff1f9634f281f97729cab to your computer and use it in GitHub Desktop.
export-onnx-model-from-mlnet-model
var onnxPath = GetOutputPath(subDir, "SaveModelToOnnxTest.onnx");
var onnxAsJsonPath = GetOutputPath(subDir, "SaveModelToOnnxTest.json");
OnnxConverter converter = new OnnxConverter()
{
InputsToDrop = new[] { "Label" },
OutputsToDrop = new[] { "Label", "Features" },
Onnx = onnxPath,
Json = onnxAsJsonPath,
Domain = "com.mydomain"
};
converter.Convert(model);
// Strip the version.
var fileText = File.ReadAllText(onnxAsJsonPath);
fileText = Regex.Replace(fileText, "\"producerVersion\": \"([^\"]+)\"", "\"producerVersion\": \"##VERSION##\"");
File.WriteAllText(onnxAsJsonPath, fileText);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment