godot_rl_agents_plugin icon indicating copy to clipboard operation
godot_rl_agents_plugin copied to clipboard

Using the ONNX output values

Open yaelatletl opened this issue 2 years ago • 3 comments

From https://github.com/edbeeching/godot_rl_agents/issues/23

@edbeeching I've been trying to implement the ONNX model to directly handle the agents, but it's a bit obscure. I was actually able to relate the outputs from the model to the outputs from the checkpoint and training.

Godot recieves:setting action 4 content: {jump:0, move:[-0.965605], turn:[-1]} ONNX outputs: {output:[1.830403, -1.823679, -0.965604, -2.522008, -1.960869, -2.00579], state_outs:[0]}

Godot recieves: setting action 7 content: {jump:1, move:[-1], turn:[0.057112]} ONNX outputs: {output:[-0.059597, 0.059326, -1.319151, -1.642016, 0.057112, -1.164303], state_outs:[0]}

Godot recieves: setting action 9 content: {jump:0, move:[-0.582598], turn:[-0.251385]} ONNX outputs: {output:[3.487688, -3.483186, -0.582597, -2.297049, -0.251385, -2.50098], state_outs:[0]} The index 2 relates to move and index 4 relates to turn, but I can't wrap my head around the other values, question here is, what are the other values supposed to mean? Which one represents jump?

I'm not sure if the output is complete, but the results are deterministic and coherent so far, so maybe there's something I'm missing? Any advice would be appreciated

yaelatletl avatar May 03 '23 06:05 yaelatletl

Hey, did you try the sb3 models in the latest version of the repo? I did not test the rllib export much.

edbeeching avatar May 03 '23 07:05 edbeeching

Done :-)

https://github.com/edbeeching/godot_rl_agents_examples/blob/main/examples/BallChase/addons/godot_rl_agents/onnx/csharp/ONNXInference.cs

@yaelatletl Are u only using GDScript in Godot.

Now that in 0.5 version, it is possible to export ONNX, that means one could consume the ONNX using ML.NET in Godot

@edbeeching Will you be interested to encourage users to have examples in Godot using C# and use ML.NET or ONNX Runtime to consume these exported ONNX from python?

GeorgeS2019 avatar May 17 '23 07:05 GeorgeS2019

Are u only using GDScript in Godot.

I created a fork: https://github.com/hakuhan/godot_rl_agents_plugin which using gdextension to load onnx model (By loading ONNXRuntime libs). I compiled/tested/pushed linux version of gdextension.

hakuhan avatar Jun 02 '24 03:06 hakuhan