tf in nodejs

188 views
Skip to first unread message

Ranaivoson Herimanitra

unread,
May 19, 2018, 9:56:09 AM5/19/18
to TensorFlow.js Discussion

Has someone managed to have  a working example using nodejs backend like express?

I've tone of issues using this :https://www.npmjs.com/package/@tensorflow/tfjs-node


One of examples errors I get after yarn start

node_modules/@tensorflow/tfjs-core/dist/engine.d.ts(65,24): error TS2304: Cannot find name 'ImageData'.
node_modules/@tensorflow/tfjs-core/dist/engine.d.ts(65,36): error TS2304: Cannot find name 'HTMLImageElement'.
node_modules/@tensorflow/tfjs-core/dist/engine.d.ts(65,55): error TS2304: Cannot find name 'HTMLCanvasElement'.
node_modules/@tensorflow/tfjs-core/dist/engine.d.ts(65,75): error TS2304: Cannot find name 'HTMLVideoElement'.


Herimanitra,


Nick Kreeger

unread,
May 19, 2018, 10:27:23 AM5/19/18
to airma...@gmail.com, tf...@tensorflow.org
That might be an issue with your node install for your project.

Try looking at the MNIST demo for setup ideas: https://github.com/tensorflow/tfjs-node/tree/master/demo

I'd recommend deleting your node_modules folder and re-running yarn.

Ranaivoson Herimanitra

unread,
May 19, 2018, 1:13:28 PM5/19/18
to Nick Kreeger, tf...@tensorflow.org
I replace my server with the link you provide.

I npm install everything

then yarn mnist

It gives me the attached error
error.png

Ranaivoson Herimanitra

unread,
May 19, 2018, 9:08:51 PM5/19/18
to Nick Kreeger, tf...@tensorflow.org

Daniel Smilkov

unread,
May 29, 2018, 7:01:19 PM5/29/18
to airma...@gmail.com, Nick Kreeger, TensorFlow.js Discussion
Glad you figured it out. FYI, for the typescript error, if you are using tfjs-node within a typescript project, make sure you have "dom" as value in the "lib" property of your tsconfig.json (see this line). This adds typings for DOM elements which tfjs uses since it can also run in the browser.

Cheers!
Daniel


--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.
Visit this group at https://groups.google.com/a/tensorflow.org/group/tfjs/.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfjs/CAPDBDZcpMcimDW4GGC6BOoyqO5z%3DxFz4YjzS_V-5xKB0QD3F3A%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages