Skip to content
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

Adds argument to set obs key to stable_baselines_export.py #212

Merged
merged 3 commits into from
Nov 7, 2024

Conversation

Ivan-267
Copy link
Collaborator

@Ivan-267 Ivan-267 commented Nov 5, 2024

Adds the ability to change the obs key used when exporting to onnx.

Usage:

1 - In SB3 example script, find export_model_as_onnx method, and inside it set the obs_key, e.g.:

export_model_as_onnx(model, str(path_onnx), obs_keys=['obs2'])

(recommended to use a single key for now, as that's what inference supports for now)

2 - In sync node in GDRL plugin in Godot, find the _inference_process: method and set the correct key, e.g.:

			var action = model.run_inference(
				obs[agent_id]["obs2"], 1.0
			)

(this should also be adjustable in the future for each agent, but as we support only one key, it's currently only necessary for the camera sensor so the Python server can detect it as image obs and run needed processing, in other cases there's no advantage from renaming the obs key)

Note

If you don't set the key or modify anything, obs will be used by default as before. This is the default which all examples use.

Note

Onnx export/inference with the camera sensor is not guaranteed to work with this update. SB3/Rllib and other frameworks can do their own pre-processing which adds complexity to the implementation. However, this PR is still a required step toward it.

@Ivan-267 Ivan-267 merged commit 53cb02a into main Nov 7, 2024
13 checks passed
@Ivan-267 Ivan-267 deleted the adds_set_obs_key_to_onnx_export branch November 7, 2024 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants