edbeeching / godot_rl_agents

An Open Source package that allows video game creators, AI researchers and hobbyists the opportunity to learn complex behaviors for their Non Player Characters or agents
MIT License
902 stars 63 forks source link

Inference does not work with exported game #183

Closed sz655321 closed 4 months ago

sz655321 commented 4 months ago

Hello everyone,

I am currently working on a project for my master's degree. I am using Godot 4.2.2 mono and have trained a simple AI. When I export the model to ONNX, the inference works fine if I run the game from the Godot IDE. Unfortunately, when I export the game to Windows or Linux arm64, the game starts but shuts down immediately:

Screenshot 2024-05-08 142807

I have checked that the file model.onnx is in the same place of the executables as before in the IDE. If I remove the model.onnx file, the game keeps running without crashing, but repeatedly outputs the error:

Screenshot 2024-05-08 143519

From this behavior I conclude that the problem is not in my implementation, but somehow the inferrence does not work with exported games in Godot 4.2.2. Could anyone reproduce this or succesfully use onnx inferrence with a exported game?

I would be very happy if someone could help me with my problem. Thanks in advance Stephan

Ivan-267 commented 4 months ago

Hello,

I re-checked export with a simple test env that is WIP: https://github.com/edbeeching/godot_rl_agents_examples/pull/33 on Godot 4.3.dev5 and Windows 64 bit (x64) and the exported .exe with onnx in the same folder is working.

It should work with Linux too, but I haven't tested this or any OS on arm64 myself, maybe something could be different.

Onnx in exported games also worked previously for me, so the newer Godot version shouldn't be important here.

I wonder if you could also try exporting one of the examples that has an onnx file attached (https://github.com/edbeeching/godot_rl_agents_examples/tree/main/examples, or the simple test env above, although it uses a newer Godot version), just to try to locate the problem further.

sz655321 commented 4 months ago

Hello,

thanks for the quick reply. I tried the BallChase example and everything worked perfectly. I realized that somehow in my project the folder data_Game_windows_x86_64 was not created when exporting. I also had no Game.sln somehow. Now I changed everything to match the BallChase example and was able to export and use the inference in the exported game. FYI: I also tried exporting to arm64 and everything runs fine on my Raspberry Pi 4.

Thanks for the help :)