Using the libraries in non-browser NodeJS
See original GitHub issue(node:3904) UnhandledPromiseRejectionWarning: ReferenceError: FileReader is not defined
at D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-core\dist\io\browser_files.js:160:42
at new Promise (<anonymous>)
at BrowserFiles.<anonymous> (D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-core\dist\io\browser_files.js:159:39) at step (D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-core\dist\io\browser_files.js:48:23)
at Object.next (D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-core\dist\io\browser_files.js:29:53)
at D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-core\dist\io\browser_files.js:23:71
at new Promise (<anonymous>)
at __awaiter (D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-core\dist\io\browser_files.js:19:12)
at BrowserFiles.load (D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-core\dist\io\browser_files.js:153:16)
at D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-layers\dist\models.js:279:50
at step (D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-layers\dist\models.js:54:23)
at Object.next (D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-layers\dist\models.js:35:53)
at D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-layers\dist\models.js:29:71
at new Promise (<anonymous>)
at __awaiter (D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-layers\dist\models.js:25:12)
at loadLayersModelFromIOHandler (D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-layers\dist\models.js:267:12) at Object.<anonymous> (D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-layers\dist\models.js:251:35)
at step (D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-layers\dist\models.js:54:23)
at Object.next (D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-layers\dist\models.js:35:53)
at D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-layers\dist\models.js:29:71
at new Promise (<anonymous>)
at __awaiter (D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-layers\dist\models.js:25:12)
at Object.loadLayersModelInternal (D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-layers\dist\models.js:230:12) at Object.loadLayersModel (D:\Code\JS\SAHBot\node_modules\@tensorflow\tfjs-layers\dist\exports.js:224:21)
at Object.<anonymous> (D:\Code\JS\SAHBot\node_modules\@teachablemachine\image\dist\custom-mobilenet.js:378:49) at step (D:\Code\JS\SAHBot\node_modules\@teachablemachine\image\dist\custom-mobilenet.js:49:23)
at Object.next (D:\Code\JS\SAHBot\node_modules\@teachablemachine\image\dist\custom-mobilenet.js:30:53)
at D:\Code\JS\SAHBot\node_modules\@teachablemachine\image\dist\custom-mobilenet.js:24:71
(node:3904) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:3904) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
my code:
const tf = require("@tensorflow/tfjs");
const tfn = require("@tensorflow/tfjs-node");
const tmImage = require('@teachablemachine/image');
tmImage.loadFromFiles('model.json', 'weights.bin', 'metadata.json').then(model => {
...
});
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (4 by maintainers)
Top Results From Across the Web
How can I use the same library in Node AND a browser while ...
I wanted a single solution that worked in any case. The solution that I decided to use was to: Always use Node.JS require('<npm...
Read more >The Future of Native Modules in Node.js - NearForm
A new minimal standard library, composed with some essential features needed for writing non-browser applications, such as filesystem ...
Read more >setupServer() - Api - Mock Service Worker Docs
This function is designed for NodeJS environment. If looking for a way to apply API mocking in a browser environment, consider using setupWorker ......
Read more >How to bundle your library for both NodeJS and Browser with ...
externals — where we use webpack-node-externals module to define the externals modules that should not be bundled (in our case node-fetch) . At ......
Read more >Node.js - Reviews, Pros & Cons
See what developers are saying about how they use Node.js. Check out popular companies that use Node.js and some tools that integrate with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found this issue when I was trying to figure out how to use my teachable machine model in Node.js. I thought I would comment in case others end up here wondering how to use their model in Node.js with Tensorflow.js. I created a starting template that might be helpful to others. (FYI it is not using the teachable machine library, only its exported trained model.)
https://github.com/traumverloren/teachable-machine-image-nodejs-starter
Hi @tr7zw and @steamp0rt thanks for filing the issue. We are working on the savedmodel export it should be fixed soon.
And you’re right we have not implemented nodeJs support. It’s good to know that you would like to use it in this environment and we’ll keep it in mind for future planning.