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

Exporting A Game. How it works? #1

Open
nonunknown opened this issue Oct 17, 2021 · 11 comments
Open

Exporting A Game. How it works? #1

nonunknown opened this issue Oct 17, 2021 · 11 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@nonunknown
Copy link

nonunknown commented Oct 17, 2021

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)?

@edbeeching edbeeching added enhancement New feature or request good first issue Good for newcomers labels Oct 17, 2021
@edbeeching edbeeching self-assigned this Oct 17, 2021
@edbeeching edbeeching added this to the 0.2.0 milestone Oct 17, 2021
@edbeeching
Copy link
Owner

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).

@araffin
Copy link

araffin commented Oct 17, 2021

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

@nonunknown
Copy link
Author

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++...

@edbeeching
Copy link
Owner

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.

@nonunknown
Copy link
Author

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?

@GeorgeS2019
Copy link

@edbeeching

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

@KeithKeyes
Copy link

KeithKeyes commented Apr 20, 2022

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 ^_^.

@indiejames
Copy link

Is there any progress on this? Would be great to be able to use a trained model to do inferencing on a mobile device.

@Ivan-267
Copy link
Collaborator

Ivan-267 commented Oct 11, 2023

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.

@edbeeching
Copy link
Owner

edbeeching commented Oct 12, 2023

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.

@edbeeching
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

7 participants