Wednesday, 3 May 2017

Node Keras-js: Cannot read property 'source' of undefined

I am trying to do image predictions using trained Keras model in a Node backend.

I am trying to achieve this using the Keras-js npm module: https://github.com/transcranial/keras-js

But I am facing an error that says:"Cannot read property 'source' of undefined"

I only have these few lines of codes:

const KerasJS = require('keras-js');

// in node, gpu flag will always be off
// paths can be filesystem paths or absolute URLs
// if filesystem path, this must be specified:

const model = new KerasJS.Model({
  filepaths: {
    model: 'model.json',
    weights: 'first_try_weights.buf',
    metadata: 'first_try_metadata.json'
  },
  filesystem: true
})

I have installed keras-js using

npm install keras-js --save

At first it is complaining a babel-polyfill related error.

Then I installed that:

npm install babel-polyfill --save

Then I am facing this error:

node-test/node_modules/keras-js/lib/Model.js:67
var axiosSource = _axios2.default.CancelToken.source();
                                             ^

TypeError: Cannot read property 'source' of undefined
    at Object.<anonymous> (.../Keras/node-test/node_modules/keras-js/lib/Model.js:67:46)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (.../Keras/node-test/node_modules/keras-js/lib/index.js:10:14)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)

What is that?



via mkto

No comments:

Post a Comment