Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tadvas opened this issue May 5, 2023 · 1 comment
Open

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

tadvas opened this issue May 5, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@tadvas
Copy link

tadvas commented May 5, 2023

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 tadvas added the bug Something isn't working label May 5, 2023
@codeandcats
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants