Skip to content

tfjs-lite not runing #8512

Open
Open
@AbdullahElsheshtawy

Description

@AbdullahElsheshtawy

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/[email protected]/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}`);
}

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions