Open krumiaa opened 5 years ago
Use an api exposed to Unreal such as https://github.com/getnamo/tensorflow-ue4.
@krumiaa Hi. Do you find any solution? I writed some code that you want to use 'TFJS'. Check my repo(https://github.com/keicoon/Deep-Learning/tree/master/DQN). It has dependencies about unreal.js and @tensorflow/tfjs.
Did you get this DQN repo to work with Unreal.js? When I tried to load tfjs as a dependency, it threw a bunch of errors....
You don't need to install npm/@tfjs directly, just inject js code const tf = require('./lib/fancyLoadNPM')('@tensorflow/tfjs', global);
.
It help that loads cycling dependancies by downloading tfjs and making to bundle.
Still not sure how you got this working keicoon , was it with a node install of tensorflow.js or via npm? Trying to run example-dqn-tfjs.js from your DQN repository, kept pulling errors like module ReferenceError: module is not defined or ReferenceError:process is not defined. Is it possible you could share the unreal project file or do a step by step run through of the install. I tried it on Unreal 4.19
@krumiaa Hi! Thanks for your review. It has some problem due to npm's latest update that not allowed '@' keyword by module name. So, I updated github code and uploaded full content
be tested in UE4.19 project to gitlab.
Tried the project from getlab as well as the new github code but getting error: Cannot read property 'train' of undefined. See image. Thinking this maybe some version specific glitch. Am using npm 6.4.1 and Unreal.js ver 0.3.1 with Unreal 4.19. I didnt see that tensorflow was installed in the scripts directory of your project so i tried npm install @tensorflow/tfjs to the /scripts but still not working. Any other
suggestions for how to replicate this? Maybe I'm missing something obvious?
Hi!
I am using tensorflow.js bundle file that made by browserify
. It will be generated by Scripts/bundle_tensorflow_tfjs.js
. So, you first check bundle_tensorflow_tfjs.js
file be existed. If not existed, Run below command repeatedly until tf
is not empty.
tf = require('dqn\lib\fancyLoadNPM')('@tensorflow/tfjs', global)
console.log(tf)
If you don't want to follow, you can also make bundle file using browserify
by independent command.
Thank YOU :)
Thank you so much for helping explain this. After hours and hours, I still have not managed to get it working. Do I need browserfy installed in order to run the project as you have made it? the only way i get console.log(tf) to rerturn anything is with const tf = require('/dqn/lib/fancyLoadNPM')('bundle_tensorflow_tfjs.js', global); but this creates multiple versions of bundle_tensorflow_tfjs.js in the scripts directory and basic tensorflow functions like const model = tf.sequential(); still wont work. Any change u could post some stimple step by step setup instructions for loading all the dependencies on the github page?
@krumiaa looking at fancyLoadNPM, it appears to require you to have node installed separately, do you have it installed?
Yes, this solution need to install nodejs that he said.
Because, I use command(JavascriptProcess.Create('node', ...)
) that has dependency about nodejs.
Let's install nodejs 8.x.x. :)
Curious if anyone has managed to replicate this and what if any changes were necessary? Iv been banging my head against it for a week. Yes, have node 8.12 installed. Wondering if there are some build path issues with the fancyLoadNPM code, parts that have to be modified depending on where node was installed or where game assets are located. Or perhaps dependent on using a particular version of node. Cant think of any other reasons the project file wouldn’t work out of the box. Or perhaps Browserify must be installed at a particular location, noticed its referenced in fancyLoadNPM. Allot of moving parts. Not even sure why FancyLoadNPM is required, what purpose it is serving here different from NPM. Would be helpful if some of this was laid out in the documentation, though I suppose that would take away all the fun ;-)
Simply, I would explain why need to use browerify
and node
that not v8
. First unreal.js not support npm module officially so we can't use @tensorflow.js
directly. And v8 is different to node about loading module system has circularly issue. So, I use trick will resolve circular dependency module issue using browserify
. Lastly, I will upload bundle script that be browserified about tensorflow.js for you :)
Very much appreciate the work you have done on this keicoon and believes it really opens up some cool possibilities for doing machine learning in Unreal. Really confused on how to replicate though so anything you can do to make the process simpler, such as the bundle script you mentioned, would be awesome.
@krumiaa Hi!
Download this file bundle_tensorflow_tfjs.js.
and put it in Content\Scripts
:)
Hi keicoon, thanks for uploading this. I noticed a similar bundle file in your unreal project scripts directory, wasn't sure what the the proper way to deploy it is. Does one still need the fancyLoadNPM to access this bundle file or can I just call it like const tf = require('bundle_tensorflow_tfjs', global); Thanks for clarifying
I got this to work as well very cool! Didn't even think about possibilities with tensorflow etc cool stuff! I hope to share some cool stuff soon.
Ran into errors getting this to work with Tensorflow.js, specifically SyntaxError: Unexpected token when using import as tf from '@tensorflow/tfjs'; to load the tensor flow. Is Unreal JS fundamentally incompatible with external packages like Tensorflow or am I missing something?