teachablemachine-community icon indicating copy to clipboard operation
teachablemachine-community copied to clipboard

[BUG]: tmImage doesn't work and throws an error around fetch()

Open tadvas opened this issue 2 years ago • 1 comments
trafficstars

Describe the bug The goal is to create nodejs client, which will make predictions based on the model, generated by TM

However, it's not possible to use tmImage()

To Reproduce Steps to reproduce the behavior:

const tmImage = require('@teachablemachine/image');
const URL = 'https://teachablemachine.withgoogle.com/models/NujXJZDb4/';

async function init() {
  const modelURL = URL + 'model.json';
  const metadataURL = URL + 'metadata.json';

  model = await tmImage.load(modelURL, metadataURL);

  console.log('works')
}

init();

Stack trace: ReferenceError: fetch is not defined at /Users//Desktop/img/node_modules/@teachablemachine/image/dist/custom-mobilenet.js:153:17 at step (/Users//Desktop/img/node_modules/@teachablemachine/image/dist/custom-mobilenet.js:49:23) at Object.next (/Users//Desktop/img/node_modules/@teachablemachine/image/dist/custom-mobilenet.js:30:53) at /Users//Desktop/img/node_modules/@teachablemachine/image/dist/custom-mobilenet.js:24:71 at new Promise () at __awaiter (/Users//Desktop/img/node_modules/@teachablemachine/image/dist/custom-mobilenet.js:20:12) at processMetadata (/Users//Desktop/img/node_modules/@teachablemachine/image/dist/custom-mobilenet.js:147:52) at Object. (/Users//Desktop/img/node_modules/@teachablemachine/image/dist/custom-mobilenet.js:360:42) at step (/Users//Desktop/img/node_modules/@teachablemachine/image/dist/custom-mobilenet.js:49:23) at Object.next (/Users/***/Desktop/img/node_modules/@teachablemachine/image/dist/custom-mobilenet.js:30:53)

Expected behavior The function works w/o errors

tadvas avatar May 05 '23 09:05 tadvas

@tadvas did you find a way to get this working in nodejs? If not, did you find another solution?

codeandcats avatar Oct 08 '23 08:10 codeandcats