• Stars
    star
    218
  • Rank 180,822 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Drag and drop Unreal Engine TensorFlow examples repository.

TensorFlow Unreal Plugin Examples

GitHub release Github All Releases

Example content project for tensorflow-ue4 plugin.

This repository also tracks changes required across all dependencies to make tensorflow work well with UE4.

See issues for current work and bug reports.

Unreal Forum Thread

Setup

  1. (GPU only) Install CUDA and cudNN pre-requisites if you're using compatible GPUs (NVIDIA)
  2. Download latest project release
  3. Download the matching tensorflow plugin release. Choose CPU download (or GPU version if hardware is supported). The matching plugin link is usually found under the project release.
  4. Browse to your extracted project folder
  5. Copy Plugins folder from your plugin download into your Project root.
  6. Launch and wait for tensorflow dependencies to be installed. The tensorflow plugin will auto-resolve any dependencies listed in Plugins/tensorflow-ue4/Content/Scripts/upymodule.json using pip. Note that this step may take a few minutes and depends on your internet connection speed and you will see nothing change in the output log window until the process has completed.

image

  1. Once you see an output similar to the above in your console window, everything should be ready to go, try different examples from e.g. Content/ExampleAssets/Maps!

Note on cloning the repository

If you're not using a release, but instead wish to clone the repository using git. Ensure you follow TensorFlow-ue4 instructions on cloning.

Examples

Mnist recognition

Map is found under Content/ExampleAssets/Maps/Mnist.umap and it should be the default map when the project launches.

mnist spawn samples

Default mnist example script: mnistSpawnSamples.py

On map launch you'll have a basic example ready for play in editor. It should automatically train a really basic network when you hit play and then be ready to use in a few seconds. You can then press 'F' to send e.g. image of a 2 to predict. Press 0-9 numbers on your keyboard to change the input, press F again to send this updated input to classifier. Note that this is a very basic classifier and it will struggle to classify digits above 4 in the current setup.

Classifying custom data

You can change the input to any UTexture2D you can access in your editor or game, but if the example is using a ConnectedTFMnistActor you can also use your mouse/fingers to draw shapes to classify. Simply go to http://qnova.io/e/mnist on your phone or browser after your training is complete, then draw shapes in your browser and it will send those drawn shapes to your UE4 editor for classification.

custom classification

Note that only the latest connected UE4 editor will receive these drawings, if it's not working just restart your play in editor to become the latest editor that connected. You can also host your own server with the node.js server module found under: https://github.com/getnamo/TensorFlow-Unreal-Examples/tree/master/ServerExamples. If you want to connect to your own server, change the ConnectedTFMnistActor->SocketIOClient->Address and Port variable to e.g. localhost:3000.

Other classifiers e.g. CNN Keras model

If you want to try other mnist classifiers models, change your ConnectedTFMnistActor->Python TFModule variable to that python script class. E.g. if you want to try the Keras Convolutional Neural Network Classifier change the module name to mnistKerasCNN and hit play. Note that this classifier may take around 18 min to train on a CPU, or around 45 seconds on a GPU. It should however be much more accurate than the basic softmax classifier used by default.

See available classifier models provided here: https://github.com/getnamo/TensorFlow-Unreal-Examples/tree/master/Content/Scripts

Saving / Loading Models

mnistSaveLoad python script will train on the first run and then save the trained model. Each subsequent run will then use that trained model, skipping training. You can also copy and paste this saved model to a new project and then when used in a compatible script, it will also skip the training. Use this as a guide to link your own pre-trained network for your own use cases.

You can force retraining by either changing ConnectedTFMnistActor->ForceRetrain to true or deleting the model found under Content/Scripts/model/mnistSimple

Basic Tensorflow Example - Addition & Subtraction of Float Arrays

Map is found under Content/ExampleAssets/Maps/Basic.umap

basic example

Uses TFAddExampleActor to encapsulate addExample.py. This is a bare bones basic example to use tensorflow to add or subtract float array data. Press 'F' to send current custom struct data, press 'G' to change operation via custom function call. Change your default ExampleStruct a and b arrays to change the input sent to the tensorflow python script.

Other Examples

If you have other examples you want to implement, consider contributing or post an issue with a suggestion.

Tensorflow API

See https://github.com/getnamo/tensorflow-ue4 for latest documentation.

Dependencies

depends on:

https://github.com/getnamo/tensorflow-ue4

https://github.com/getnamo/UnrealEnginePython

https://github.com/getnamo/socketio-client-ue4

Troubleshooting

Startup Error

If you're seeing something like

no plugins error

You did not follow step 3. in setup. Each release has a matching plugin that you need to download and drag into the project folder.

Video

There's a video made by github user Berranzan that walks through setting up the tensorflow examples for 4.18 with GPU support.

Neural networks on UE4

For issues not covered in the readme see:

https://github.com/getnamo/TensorFlow-Unreal-Examples/issues

and

https://github.com/getnamo/TensorFlow-Unreal/issues

Presentation

Example project used in the presentation https://drive.google.com/open?id=1GiHmYJeZI6BKUKYfel6xc0YFhMbjSOoCY17nl98dihA contained in https://github.com/getnamo/TensorFlow-Unreal-Examples/tree/presentation branch

Second presentation with 0.4 api: https://docs.google.com/presentation/d/1p5p6CjYYYfbflFpvr104U1GwrfArfl4Hkcb6N3SIBH8

More Repositories

1

TensorFlow-Unreal

TensorFlow plugin for the Unreal Engine.
C++
1,133
star
2

SocketIOClient-Unreal

Socket.IO client plugin for the Unreal Engine.
C++
845
star
3

UDP-Unreal

Convenience UDP wrapper for the Unreal Engine.
C++
293
star
4

GlobalEventSystem-Unreal

Loosely coupled internal event system plugin for the Unreal Engine.
C++
257
star
5

NodeJs-Unreal

Embed node.js as an Unreal Engine plugin.
C++
238
star
6

7zip-cpp

Fork of SevenZip++ for modern builds.
C++
206
star
7

ZipUtility-Unreal

Event driven 7zip utility plugin for the Unreal Engine.
C++
194
star
8

MachineLearningRemote-Unreal

Machine Learning plugin for the Unreal Engine, encapsulating calls to remote python servers running e.g. Tensorflow/Pytorch.
C++
135
star
9

TCP-Unreal

Convenience TCP wrapper for Unreal Engine
C++
96
star
10

SocketIOClient-Unreal-Example

sample project using the socketio-client-ue4
HTML
88
star
11

hydra-ue4

Hydra Plugin for Unreal Engine 4
C++
75
star
12

myo-ue4

Myo Plugin for Unreal Engine 4
C++
51
star
13

TensorFlowNative-Unreal

Tensorflow Plugin for Unreal Engine using C API for inference focus.
C#
42
star
14

realsense-ue4

RealSense plugin for Unreal Engine 4
C++
40
star
15

RuntimeGeometryUtils

Fork of https://github.com/gradientspace/UnrealRuntimeToolsFrameworkDemo plugin for inclusion as submodule
C++
23
star
16

ml-remote-server

Server component of https://github.com/getnamo/machine-learning-remote-ue4
Python
22
star
17

WeaponTrace-Unreal

WeaponTracing plugin for reliable melee combat.
20
star
18

CIMPlugin

Custom Input Mapping Plugin for the Unreal Engine 4
C++
19
star
19

UE4-MouseIKThirdPerson

Simple Unreal Engine third person template project with mouse click left arm movement.
15
star
20

VRArmIK-ue4

UE4 port of https://github.com/dabeschte/VRArmIK
C++
12
star
21

BodyState-Unreal

An abstract skeleton target for body tracking input devices
C++
10
star
22

RVD-Unreal

Real-time Value Debugger for the Unreal Engine.
C++
10
star
23

TensorFlowJs-Unreal

Tensorflow.js Plugin for Unreal Engine using Node.js plugin.
C#
8
star
24

socketio-client-prebuild

socket io client static library builds for UE4
Batchfile
7
star
25

BulkManager-Unreal

Plugin for managing a bulk of actors with data through programmatic relevancy.
C++
7
star
26

EnvCommand-Unreal

Access environment commands from bps
C++
6
star
27

SIONetworking-Unreal

simple echo networking using socket.io and ges
JavaScript
6
star
28

mnist-draw-server

server counterpart for drawing on webclients and sending via socket.io to ue4 mnist classifier client
JavaScript
3
star
29

clean-ue4

Simple npm script to clean Intermediate, Saved folders, and .pdbs from unreal projects and plugins for release prep.
JavaScript
2
star
30

BasicDatabase-Unreal

Simple wrapped DB API for json flatfile database & potentially more backends.
C++
2
star
31

PiperCLI-Unreal

Experimental Piper plugin for Unreal via CLI wrapper.
C++
2
star
32

AnswerHubMisc

Various answer/example projects
1
star
33

batch-resizer

Batch resize images using npm sharp and exif-parser
JavaScript
1
star
34

Adeept_RaspClaws

Python
1
star