Hey Drstreit,
In the tutorial, the returned unique pointer that you get from CreateModelCPU (indicating the caller becoming the owner of the model) is converted to a shared pointer.
The shared pointer can be passed to any thread / task for execution e.g. by using AsyncTask.
For instance, you can pass the model in the capture list of the lambda function, RunSync inside (which is carried out on a separate thread) and then pushing the results back to the game thread with another AsyncTask launched to ENamedThreads::GameThread.
There are two difficulties you need to take care of:
- The memory that is passed as input / output to the model must stay valid throughout execution (Which you can achieve easily e.g. by copying data to the thread and back (at the cost of efficiency due to memory copying)).
- You must make sure the model finished evaluation before you stop the game (if the game crashes when you quit, it usually means that some model was still running).
I hope that helped?
I am not sure what you mean by ‘include BP as option’. The tutorial wraps the NNE models in Blueprint functions as an illustrative example, but of course you can call everything from any c++ code you want.
If you want to work on screenshots, you may want to look into FSceneViewExtensionBase and use an RDG runtime to directly process a render target inside the render pipeline.
Does this answer your question?