Skip to content

Support for ONNX export #3101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Feb 18, 2020
Merged

Support for ONNX export #3101

merged 28 commits into from
Feb 18, 2020

Conversation

chriselion
Copy link
Contributor

@chriselion chriselion commented Dec 18, 2019

Adds support for exporting to ONNX format. This will be disabled by default, and enabled if the tf2onnx package is installed. A recent version (>=1.5.5) is recommended. Note that tf2onnx is not currently compatible with tensorflow 2.0.0 or higher.

ONNX files generated from ML-Agents can only be imported with Barracuda v0.6.0 or later.

Other notable changes:

  • the min supported version of numpy has increased to 1.14.1

@chriselion chriselion changed the title Develop onnx prototype Support for ONNX export Feb 13, 2020
@chriselion chriselion marked this pull request as ready for review February 14, 2020 01:55
@chriselion
Copy link
Contributor Author

I cancelled the yamato tests. Will add changelog entries after the release branch is merged to master.

@@ -0,0 +1,205 @@
import logging
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to call this file onnx_serialization.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also handles the tensorflow_to_barracuda conversion (those methods were migrated out of tf_policy.py). Maybemodel_serialization.py instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eh, guess not. looks like a lot more is going on here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like model_serialization.py

@ervteng
Copy link
Contributor

ervteng commented Feb 14, 2020

This doesn't yet do ONNX -> Barracuda right? The export part LGTM

self.get_policy(name_behavior_id).export_model()
policy = self.get_policy(name_behavior_id)
settings = SerializationSettings(policy.model_path, policy.brain.brain_name)
export_policy_model(settings, policy.graph, policy.sess)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Do like moving exporting out of Policy

Copy link
Contributor

@ervteng ervteng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@chriselion
Copy link
Contributor Author

@ervteng Barracuda importer will handle everything, we just need to export the ONNX.

@@ -27,10 +27,17 @@ but we only tested for the following platforms :
* iOS
* Android

## Supported formats
There are currently two supported model formats:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@surfnerd @ervteng - I made this change to the docs too. Can you take a look when you get a chance? (I might merge first and revise if needed).

@chriselion chriselion merged commit a5626aa into master Feb 18, 2020
@delete-merged-branch delete-merged-branch bot deleted the develop-onnx-prototype branch February 18, 2020 17:54
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants