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

Initialization of backend wasm failed #931

Open
DaiHaoguang3151 opened this issue Jan 3, 2024 · 0 comments
Open

Initialization of backend wasm failed #931

DaiHaoguang3151 opened this issue Jan 3, 2024 · 0 comments

Comments

@DaiHaoguang3151
Copy link

code:
`import React, { useState, useRef } from "react";
import * as faceapi from 'face-api.js'
import * as tf from '@tensorflow/tfjs-core';
import { setWasmPaths } from "@tensorflow/tfjs-backend-wasm";

const App = () => {
const [session, setSession] = useState(null);
const [loading, setLoading] = useState("Loading OpenCV.js...");

async function init() {
    // setWasmPaths('https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm/dist/');
    // setWasmPaths('../node_modules/@tensorflow/tfjs-backend-wasm/dist/');
    setWasmPaths(`${process.env.PUBLIC_URL}/static/js/`);
    await tf.setBackend('wasm');
    await tf.ready();
    console.log(tf.getBackend())  // webgl
}
init();

cv["onRuntimeInitialized"] = async () => {
    await faceapi.nets.mtcnn.loadFromUri("/model");
    await faceapi.nets.faceLandmark68Net.loadFromUri("/model");
    await faceapi.nets.faceRecognitionNet.loadFromUri("/model");

    console.log("backend==> ", tf.getBackend())  // webgl
    setLoading(false);
}

console.log("here backend==> ", tf.getBackend())  // wasm

return (
    <div className="App">
        
    </div>
);

};

export default App;`

dependencies:
"@tensorflow/tfjs": "^4.15.0",
"@tensorflow/tfjs-backend-wasm": "^4.15.0",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^13.0.0",
"@testing-library/user-event": "^13.2.1",
"face-api.js": "^0.22.2",
"onnxruntime-web": "^1.11.0",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.0"

1704270302613

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

No branches or pull requests

1 participant