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

Facelandmarker failed to load inside a module web worker #5527

Open
Hamed-Hassanzadeh opened this issue Jul 10, 2024 · 1 comment
Open

Facelandmarker failed to load inside a module web worker #5527

Hamed-Hassanzadeh opened this issue Jul 10, 2024 · 1 comment
Assignees
Labels
os:windows MediaPipe issues on Windows platform:javascript MediaPipe Javascript issues stat:awaiting googler Waiting for Google Engineer's Response task:face landmarker Issues related to Face Landmarker: Identify facial features for visual effects and avatars. type:feature Enhancement in the New Functionality or Request for a New Solution

Comments

@Hamed-Hassanzadeh
Copy link

Hamed-Hassanzadeh commented Jul 10, 2024

Have I written custom code (as opposed to using a stock example script provided in MediaPipe)

Yes

OS Platform and Distribution

Windows 10, Chrome 126

MediaPipe Tasks SDK version

0.10.14

Task name (e.g. Image classification, Gesture recognition etc.)

Face Landmarker

Programming Language and version (e.g. C++, Python, Java)

JavaScript

Describe the actual behavior

Module scripts don't support importScripts() so when you try to run face landmarker in a module web worker it throws an error

Describe the expected behaviour

Should be able to run face landmarker in a module web worker

Standalone code/steps you may have used to try to get what you need

From the main thread:
const myWorker = new Worker("worker.js", { type: "module" });


--------------
worker.js:

import vision from "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision/vision_bundle.js";
const { FaceLandmarker, FilesetResolver, DrawingUtils } = vision;

async function createFaceLandmarker() {
  const filesetResolver = await FilesetResolver.forVisionTasks(
    "https://cdn.jsdelivr.net/npm/@mediapipe/[email protected]/wasm"
  );
  faceLandmarker = await FaceLandmarker.createFromOptions(filesetResolver, {
    baseOptions: {
      modelAssetPath: `https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task`,
      delegate: "GPU"
    },
    outputFaceBlendshapes: true,
    runningMode: "IMAGE",
    numFaces: 1
  });
}
createFaceLandmarker();

------

Error message:

vision_bundle.js:1 Uncaught (in promise) TypeError: Failed to execute 'importScripts' on 'WorkerGlobalScope': Module scripts don't support importScripts().
    at o (vision_bundle.js:1:452684)
    at Array.map (<anonymous>)
    at i (vision_bundle.js:1:452810)
    at createTaskRunner (vision_bundle.js:1:454548)
    at TaskRunner.createInstance (vision_bundle.js:1:454769)
    at VisionTaskRunner.createVisionInstance (vision_bundle.js:1:460257)
    at M.createFromOptions (vision_bundle.js:1:596091)
    at createFaceLandmarker (worker.js:10:47)

Other info / Complete Logs

The "runScript" helper function (https://github.com/google-ai-edge/mediapipe/blob/master/mediapipe/web/graph_runner/run_script_helper.ts.template) needs to get updated to support both the classic web workers and module web workers.
@kuaashish kuaashish self-assigned this Jul 12, 2024
@kuaashish kuaashish added os:windows MediaPipe issues on Windows task:face landmarker Issues related to Face Landmarker: Identify facial features for visual effects and avatars. platform:javascript MediaPipe Javascript issues type:support General questions labels Jul 12, 2024
@kuaashish
Copy link
Collaborator

Hi @Hamed-Hassanzadeh,

Currently, the web worker is not very familiar with our task API. However, we are marking this as a feature request and will share it with the team to ensure it is on our radar. We will consider making it more user-friendly if there is more demand in the near future.

Thank you!!

@kuaashish kuaashish added type:feature Enhancement in the New Functionality or Request for a New Solution and removed type:support General questions labels Jul 29, 2024
@kuaashish kuaashish added the stat:awaiting googler Waiting for Google Engineer's Response label Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os:windows MediaPipe issues on Windows platform:javascript MediaPipe Javascript issues stat:awaiting googler Waiting for Google Engineer's Response task:face landmarker Issues related to Face Landmarker: Identify facial features for visual effects and avatars. type:feature Enhancement in the New Functionality or Request for a New Solution
Projects
None yet
Development

No branches or pull requests

3 participants