Giter Club home page Giter Club logo

ml-remote-server's Introduction

ml-remote-server

Server complement of https://github.com/getnamo/MachineLearningRemote-Unreal. Startup the server, point your MachineLearningRemote component to your server address with the script file name set in DefaultScript property and it will load on begin play.

Quick Setup

  1. Install python 3 on target machine recommended version for e.g. tensorflow: 3.7.

Option 1)Using Windows Local Server

  1. Update requirements.txt with any dependencies you need, e.g. tensorflow==2.2
  2. Double click on InstallRequirements (you may need to run this command in admin)

  1. (Optional) If you're not using the autolaunch option on MachineLearnineRemote: Double click StartupServer.bat

Option 2) Using Remote Server

  1. Pick a folder, navigate to it
  2. git clone https://github.com/getnamo/ml-remote-server.git
  3. Update requirements.txt with any dependencies you need, e.g. tensorflow==2.2
  4. run pip install -r requirements.txt.
  5. In terminal type python server.py to start the server

Server is now ready to use.

Optional Client Steps

  1. Connect your unreal instance via https://github.com/getnamo/MachineLearningRemote-Unreal
  2. Listen to log events via your browser by going to <server ip>:8080 or localhost:8080 in your browser. There are some debug commands like /r <script name> to swap script and /i to send dummy inputs; see https://github.com/getnamo/ml-remote-server/blob/master/server.py#L117 for all supported commands.

How to use

Startup event flow

Begin Play -> (if connect on beginplay) connect to backend -> (if start script on connection) Default Script start

Listen to the OnScriptStarted event to know it's safe to send inputs/start training.

API

See https://github.com/getnamo/MachineLearningRemote-Unreal as all interaction beyond debugging is handled by client.

Keep in mind that you can end play, do some code changes, and begin playing again without rebooting your server; the default script will be reloaded. You can also use the debug browser with /r <script name> or call StartScript from MachineLearningRemote component to live reload a script even during play.

ml-remote-server's People

Contributors

dependabot[bot] avatar dyanni3 avatar getnamo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ml-remote-server's Issues

ModuleNotFoundError for scripts in scripts directory

Really awesome work you've done with this project. I am having an issue with the setup following the instructions of linking this to the MachineLearningRemote component in UE4. It keeps not finding the DefaultScript saying scripts/ not found. Here is the full traceback.

In [6]: !python server.py
MLPluginAPI imported
link set
======== Running on http://0.0.0.0:8080 ========
(Press CTRL+C to quit)
connect kAmg2jtkoneDAVTEAAAB
loading <hello.py>
Task exception was never retrieved
future: <Task finished coro=<AsyncServer._handle_event_internal() done, defined at C:\Users\LENOVO\Anaconda3\lib\site-packages\socketio\asyncio_server.py:506> exception=ModuleNotFoundError("No module named 'scripts.hello'")>
Traceback (most recent call last):
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\socketio\asyncio_server.py", line 508, in _handle_event_internal
r = await server._trigger_event(data[0], namespace, sid, *data[1:])
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\socketio\asyncio_server.py", line 542, in trigger_event
ret = await handler(*args)
File "server.py", line 103, in start_script
valid, err = mlp.load(script_name)
File "C:\Users\LENOVO\Downloads\ml-remote-server-master\mlplugin.py", line 33, in load
active_script = importlib.import_module(script_folder + '.' + script_name)
File "C:\Users\LENOVO\Anaconda3\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 953, in _find_and_load_unlocked
File "", line 219, in _call_with_frames_removed
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'scripts.hello'
sendInput: {'inputData': 'UE4 ML remote', 'targetFunction': 'onJsonInput'}
Task exception was never retrieved
future: <Task finished coro=<AsyncServer._handle_event_internal() done, defined at C:\Users\LENOVO\Anaconda3\lib\site-packages\socketio\asyncio_server.py:506> exception=RuntimeError('Task <Task pending coro=<AsyncServer._handle_event_internal() running at C:\Users\LENOVO\Anaconda3\lib\site-packages\socketio\asyncio_server.py:508>> got Future attached to a different loop')>
Traceback (most recent call last):
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\socketio\asyncio_server.py", line 508, in _handle_event_internal
r = await server._trigger_event(data[0], namespace, sid, *data[1:])
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\socketio\asyncio_server.py", line 542, in _trigger_event
ret = await handler(*args)
File "server.py", line 97, in send_input
return await future
RuntimeError: Task <Task pending coro=<AsyncServer._handle_event_internal() running at C:\Users\LENOVO\Anaconda3\lib\site-packages\socketio\asyncio_server.py:508>> got Future attached to a different loop
disconnect kAmg2jtkoneDAVTEAAAB

Initial build

  • Scaffold https://github.com/getnamo/machine-learning-remote-ue4 until connection is possible
  • Write basic socket.io host server
  • Write server MLPluginAPI wrapper script
  • Test basic examples
  • Fix multi-threading for server emits (thread calls to active script so it doesn't block emits on train)
  • Compatibility fixes
  • Documentation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.