keras-js icon indicating copy to clipboard operation
keras-js copied to clipboard

Node version doesn't work in browser

Open ViktorVaczi90 opened this issue 7 years ago • 7 comments

I use react-redux starter kit. I installed keras-js with npm install keras-js --save when I try to include {Model} from 'keras-js' then I get the following errors:

ERROR in ./~/keras-js/lib/Model.js Module not found: Error: Cannot resolve module 'fs' in /media/v/a218f425-0329-45ac-8571-5497bea24d71/home/v/workspaces/webstorm/newMIDIcheck/node_modules/keras-js/lib @ ./~/keras-js/lib/Model.js 215:50-63

ERROR in ./~/keras-js/lib/Tensor.js Module not found: Error: Cannot resolve 'file' or 'directory' ./texture_copy.glsl in /media/v/a218f425-0329-45ac-8571-5497bea24d71/home/v/workspaces/webstorm/newMIDIcheck/node_modules/keras-js/lib @ ./~/keras-js/lib/Tensor.js 142:40-70

it misses a lot of other glsl files, and yes, they aren't there. Also as far as fs goes, It shouldn't be used in the browser, how to get around that? Thanks everyone & srry for noob question.

ViktorVaczi90 avatar Mar 19 '17 14:03 ViktorVaczi90

I've also tried to use the bundle from keras-js /dist after building for browser, that one failed too.

ViktorVaczi90 avatar Mar 19 '17 14:03 ViktorVaczi90

These glsl files are missing, what is the reason behind that? They're included in this repo, but not in the node pkg.

ViktorVaczi90 avatar Mar 19 '17 14:03 ViktorVaczi90

I'm having the same problem, any news?

kmurf1999 avatar Jul 10 '17 22:07 kmurf1999

I've just deleted the file reading prop in the object + moved some glsl files and it worked for me.

ViktorVaczi90 avatar Jul 11 '17 08:07 ViktorVaczi90

where did you move the glsl files to?

kmurf1999 avatar Jul 11 '17 17:07 kmurf1999

I don't really remember. If you check the repo, you can find the missing glsl files. Move them into the same directory ( or wherever it looks for )

ViktorVaczi90 avatar Jul 11 '17 17:07 ViktorVaczi90

I've tried to use this library with npm, but also had similar problem:

These relative modules were not found:

* ./texture_copy.glsl in ./~/keras-js/lib/Tensor.js
* ./activation.glsl in ./~/keras-js/lib/ext/core/WebGLActivation.js
* ./input_transform.glsl in ./~/keras-js/lib/ext/convolutional/WebGLConv2D.js
* ./conv2d.glsl in ./~/keras-js/lib/ext/convolutional/WebGLConv2D.js
* ./maxpooling2d.glsl in ./~/keras-js/lib/ext/pooling/WebGLPooling2D.js
* ./avgpooling2d.glsl in ./~/keras-js/lib/ext/pooling/WebGLPooling2D.js
* ./batchnorm.glsl in ./~/keras-js/lib/ext/normalization/WebGLBatchNorm.js

Files was in the right places, simple copying had no effect. Finally, I solved this issue for me without copying files with changing webpack.config: From:

{ test: /\.(frag|vert)$/, use: ['raw-loader', 'glslify-loader']},
{ test: /\.(glsl)$/, use: ['raw-loader', 'glslify-loader']}

To:

{ test: /\.(glsl)$/, loader: 'url-loader'}

gmalivenko avatar Aug 01 '17 20:08 gmalivenko