Skip to content

tfjs-lite not runing #8512

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

Open
AbdullahElsheshtawy opened this issue Feb 9, 2025 · 2 comments
Open

tfjs-lite not runing #8512

AbdullahElsheshtawy opened this issue Feb 9, 2025 · 2 comments

Comments

@AbdullahElsheshtawy
Copy link

System information

  • Windows 11
  • tfjs-lite (npm)

Describe the current behavior

node_modules\@tensorflow\tfjs-tflite\dist\tf-tflite.node.js:9723
    var a = self.location, b = a.origin;
            ^

ReferenceError: self is not defined
    at module$exports$google3$third_party$tensorflow_lite_support$web$task$codegen$common$emscripten_module_loader.EmscriptenModuleLoader.getLocation (C:\dev\Arduino-Ai-Image-Classification\node_modules\@tensorflow\tfjs-tflite\dist\tf-tflite.node.js:9723:13)
    at $jscomp.generator.Engine_.program_ (C:\dev\Arduino-Ai-Image-Classification\node_modules\@tensorflow\tfjs-tflite\dist\tf-tflite.node.js:9682:333)
    at $jscomp.generator.Engine_.nextStep_ (C:\dev\Arduino-Ai-Image-Classification\node_modules\@tensorflow\tfjs-tflite\dist\tf-tflite.node.js:321:22)
    at $jscomp.generator.Engine_.next_ (C:\dev\Arduino-Ai-Image-Classification\node_modules\@tensorflow\tfjs-tflite\dist\tf-tflite.node.js:304:130)
    at $jscomp.generator.Generator_.next (C:\dev\Arduino-Ai-Image-Classification\node_modules\@tensorflow\tfjs-tflite\dist\tf-tflite.node.js:334:83)
    at b (C:\dev\Arduino-Ai-Image-Classification\node_modules\@tensorflow\tfjs-tflite\dist\tf-tflite.node.js:336:80)

Describe the expected behavior
the model loads

Standalone code to reproduce the issue
package.json

  "dependencies": {
    "@tensorflow/tfjs-backend-cpu": "^4.22.0",
    "@tensorflow/tfjs-core": "^4.22.0",
    "@tensorflow/tfjs-tflite": "0.0.1-alpha.10"
  }

index.js

import '@tensorflow/tfjs-backend-cpu';
import * as tf from '@tensorflow/tfjs-core';
import * as tflite from '@tensorflow/tfjs-tflite';

const loadModel = async (modelPath) => {
    await tflite.setWasmPath('https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-tflite@0.0.1-alpha.10/dist/');

    const response = await fetch(modelPath);
    const modelBuffer = response.arrayBuffer();

    return await tflite.loadTFLiteModel(modelBuffer);
}


function main() {
    const model = loadModel('./model/model.tflite');
    console.log(`Model: {model}`);
}
@AbdullahElsheshtawy AbdullahElsheshtawy added the type:bug Something isn't working label Feb 9, 2025
@AbdullahElsheshtawy
Copy link
Author

AbdullahElsheshtawy commented Feb 9, 2025

Just tested it works on linux but not on windows

Edit: No it does not work on linux or windows

@shmishra99
Copy link
Contributor

Hi @AbdullahElsheshtawy ,

I have tested the code snippet that you provided on macOS, and it is producing the same error.
I have included the error for your reference below. I will let you know if there are any updates regarding this issue.

    var a = self.location, b = a.origin;
            ^
ReferenceError: self is not defined
    at module$exports$google3$third_party$tensorflow_lite_support$web$task$codegen$common$emscripten_module_loader.EmscriptenModuleLoader.getLocation (/Users/name/TFJS/issue8512/node_modules/@tensorflow/tfjs-tflite/dist/tf-tflite.node.js:9723:13)
    at $jscomp.generator.Engine_.program_ (/Users/name/TFJS/issue8512/node_modules/@tensorflow/tfjs-tflite/dist/tf-tflite.node.js:9682:333)
    at $jscomp.generator.Engine_.nextStep_ (/Users/name/TFJS/issue8512/node_modules/@tensorflow/tfjs-tflite/dist/tf-tflite.node.js:321:22)
    at $jscomp.generator.Engine_.next_ (/Users/xxx/name/issue8512/node_modules/@tensorflow/tfjs-tflite/dist/tf-tflite.node.js:304:130)
    at $jscomp.generator.Generator_.next (/Users/name/TFJS/issue8512/node_modules/@tensorflow/tfjs-tflite/dist/tf-tflite.node.js:334:83)
    at b (/Users/name/TFJS/issue8512/node_modules/@tensorflow/tfjs-tflite/dist/tf-tflite.node.js:336:80)

Thank You!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants