Exporting A Game. How it works?
Opened this issue · 11 comments
So, First of all, this is an awesome project, thanks for that!
Did you tested on exported games? I took some read and seems to exist pre-trained models, so how is the approach to have an exported game which doesnt need dependencies (like python or so)?
Thanks for such a positive comment and first issue.
Regarding model export, currently the model is always hosted in python, which means python is a dependency. But this is one of the key changes that will be made in v0.2.0 (in around 1 month, see the roadmap for other changes due).
I am currently testing using the C# library TorchSharp for loading and running the trained model inside Godot, which will remove the python dependency (once the model is trained).
I am currently testing using the C# library TorchSharp for loading and running the trained model inside Godot, which will remove the python dependency (once the model is trained).
You may also take a look at ONNX export: https://stable-baselines3.readthedocs.io/en/master/guide/export.html#export-to-onnx
hmm thanks for the response! Wel When I was looking for How to implement Reiforcement Learning, I was looking for a C++ implementation, because then I could make as a GDExtension (for godot 4) then this would not require any dependencies for end-users, I found some here on gitrhub but no documentation others abandoned! I really want to use this in my project but at the end it needs to be exported, so I can help in the project, (like porting to godot 4) I just wanted a way to do it in c++...
hmm thanks for the response! Wel When I was looking for How to implement Reiforcement Learning, I was looking for a C++ implementation, because then I could make as a GDExtension (for godot 4) then this would not require any dependencies for end-users, I found some here on gitrhub but no documentation others abandoned! I really want to use this in my project but at the end it needs to be exported, so I can help in the project, (like porting to godot 4) I just wanted a way to do it in c++...
Do you need to perform the training inside Godot, or just the model inference?
A word of caution from someone who has learned this the hard way, implementing (Deep) RL algorithms can be a good learning experience, but is challenging, slow, frustrating and hard to debug. In additional I am not sure if there is a GDNative Neural Network library available, so that would need implementating as well. This is the reason I have chosen to perform training on the python side and eventually inference will be available inside Godot. There is also the benefit of running several parallel executables to speed up training.
Nope I dont want to implement it! I was just looking for a library, the thing is that seems that python is the only way out. The problem now is: how can we export a game with pre-trained models?
I am currently testing using the C# library TorchSharp for loading and running the trained model inside Godot, which will remove the python dependency (once the model is trained).
Currently Microsoft is organizing a hackathon for 1 week starting NOW!!!!. They need someone to introduce Godot and Machine learning. If you have some example, please join and share at least one Godot RL example.
If you can give us some help, please check this
Basically, we are trying to use this Godot RL example, but attempting to remove python dependency
I am currently testing using the C# library TorchSharp for loading and running the trained model inside Godot, which will remove the python dependency (once the model is trained).
looking forward to your great work! gdrl is already an amazing tool, potentially providing endless possibilities of game enviroments for testing varing RL algorithms. But, integrating the trained model into Godot engine for inference is much more attractive to us game developers anyway ^_^.
Is there any progress on this? Would be great to be able to use a trained model to do inferencing on a mobile device.
Is there any progress on this? Would be great to be able to use a trained model to do inferencing on a mobile device.
Hello, it is possible to export to onnx and run inference in Godot:
https://github.com/edbeeching/godot_rl_agents?tab=readme-ov-file#exporting-and-loading-your-trained-agent-in-onnx-format
There's some more info about using the sb3 example file:
https://github.com/edbeeching/godot_rl_agents/blob/main/docs/ADV_STABLE_BASELINES_3.md#train-a-model-in-editor
However, I have only tested this on Windows so far. An additional note is to make sure to copy the onnx file to the same relative path from the exported .exe file as specified in the sync
node in Inspector.
In Godot 4.1.2, if I try to select the Android export template, I get an error message that says: Exporting to Android is currently not supported in Godot 4 when using C#/.NET
, and we are using C# for inference.
Hi. Yes I think in Godot 4 C# is not supported yet for mobile and web export. It works for 3.5 and is it on the 4.x roadmap. So we are waiting for Godot on this one.
I will leave this open until they add the support.
Experimental support for web exports is available in this repo: https://github.com/TechnoLukas/godotrl-web/tree/main
We will try to include this in our next release.