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

Unable to find Calculator "mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"; Initialize was not ok #4200

Closed
SpookyCorgi opened this issue Mar 25, 2023 · 15 comments
Assignees
Labels
legacy:face detection Issues related to Face Detection platform:javascript MediaPipe Javascript issues type:build/install For Build and Installation issues

Comments

@SpookyCorgi
Copy link

Hi, I was trying to test out the newly committed face landmarker web api.

I build the package by running bazel build vision_pkg and then try to use it using the follow code.

   const vision = await FilesetResolver.forVisionTasks(
        "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm"
    );
    const faceLandmarker = await FaceLandmarker.createFromModelPath(vision,
        "https://storage.googleapis.com/mediapipe-tasks/face_landmarker/face_landmarker.task"
    );

However the browser is giving me the follow error.
image

Is there anything wrong within my process or is the task file still need to be updated?
Thank you.

@SpookyCorgi SpookyCorgi added the type:others issues not falling in bug, perfromance, support, build and install or feature label Mar 25, 2023
@GeorgeS2019
Copy link

@kuaashish
@schmidt-sebastian

Instead of labeling this as type:others => it would be great for the community to be type:blendshape <= soon to be hot topic for mediapipe so the community can easily track the effort done by others

Create a "mediapipe blendshape" label

@baronha
Copy link

baronha commented Mar 27, 2023

Hi, I was trying to test out the newly committed face landmarker web api.

I build the package by running bazel build vision_pkg and then try to use it using the follow code.

   const vision = await FilesetResolver.forVisionTasks(
        "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm"
    );
    const faceLandmarker = await FaceLandmarker.createFromModelPath(vision,
        "https://storage.googleapis.com/mediapipe-tasks/face_landmarker/face_landmarker.task"
    );

However the browser is giving me the follow error. image

Is there anything wrong within my process or is the task file still need to be updated? Thank you.

const vision = await FilesetResolver.forVisionTasks(
    "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm"
);

const faceLandmarker = await FaceLandmarker.createFromModelPath(vision,
    "https://storage.googleapis.com/mediapipe-tasks/face_landmarker/face_landmarker.task"
);

Where have you seen the documentation for this part? I looked on @mediapipe/tasks-vision but didn't see any mention of it at all

@schmidt-sebastian
Copy link
Collaborator

FaceLandmarker is not yet released via NPM. While you can build from source, you will need to wait for the new Wasm binaries to land on NPM. I am working on a release today, so this should be resolved soon.

@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@baronha
Copy link

baronha commented Mar 27, 2023

FaceLandmarker is not yet released via NPM. While you can build from source, you will need to wait for the new Wasm binaries to land on NPM. I am working on a release today, so this should be resolved soon.

@schmidt-sebastian
Can you tell me the specific time for the upcoming NPM release ?

@schmidt-sebastian
Copy link
Collaborator

Published: https://www.npmjs.com/package/@mediapipe/tasks-vision

@baronha
Copy link

baronha commented Mar 28, 2023

Published: https://www.npmjs.com/package/@mediapipe/tasks-vision

Thanks, @schmidt-sebastian. You are my destiny !!!

@kuaashish kuaashish added type:build/install For Build and Installation issues type:tasks Issues related to deployment of on-device ML solution platform:javascript MediaPipe Javascript issues legacy:face detection Issues related to Face Detection and removed type:others issues not falling in bug, perfromance, support, build and install or feature type:tasks Issues related to deployment of on-device ML solution labels Apr 3, 2023
@FishWoWater
Copy link

@schmidt-sebastian Hi! I have just tried the npm release with the script

   const vision = await FilesetResolver.forVisionTasks(
        "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm"
    );
    let options: FaceLandmarkerOptions = {
      baseOptions: {
        modelAssetPath:  "https://storage.googleapis.com/mediapipe-tasks/face_landmarker/face_landmarker.task"
      },
      outputFaceBlendshapes: true
    };

    const faceLandmarker = await FaceLandmarker.createFromOptions(
       vision, options
    );
    
    const image = document.getElementById("image") as HTMLImageElement;
    const landmarks = faceLandmarker.detect(image);

But the browser says [Error] Unhandled Promise Rejection: Error: StartGraph failed: $BLENDSHAPES Tag and blendshapes model must be both set. Get BLENDSHAPES is set: true, blendshapes model is set: false; Initialize was not ok
What's wrong and what should I do?

Thank you very much.

@baronha
Copy link

baronha commented Apr 22, 2023

You can download and try in your project.
blendshapes.task.zip

Here are the results I got:

Untitled.mp4

@FishWoWater
Copy link

@baronha Thank you for your help, but it has some errors too :(
The one thing I have tried that worked for me is to compress tflite models in published task file and the blendshape tflite model in this issue. Quite strange, right?
image
Could you please share you code? I am a newbie in typescript :(

@baronha
Copy link

baronha commented Apr 23, 2023

@FishWoWater

My code to initialize blendshap:

const vision = await FilesetResolver.forVisionTasks(
    "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm"
  )

const response = await FaceLandmarker.createFromOptions(vision, {
  baseOptions: {
    modelAssetPath: "asset/blendshapes.task", // your blendshape model
  },
  numFaces: 1,
  outputFaceBlendshapes: true,
  runningMode: "VIDEO",
  outputFacialTransformationMatrixes: true,
});

@FishWoWater
Copy link

@baronha still not working for me ; the initialization was ok but error occurred during inference, I guess I have problems with the calling procedure. Appreciate it a lot if you could give me some advice
image

async init(){
      const vision = await FilesetResolver.forVisionTasks(
          "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm"
      );
      let options: FaceLandmarkerOptions = {
        baseOptions: {
          modelAssetPath: "./blendshapes.task"
        },
        numFaces: 1,
        outputFaceBlendshapes: true,
        runningMode: "VIDEO",
        outputFacialTransformationMatrixes: true,

      };

      this.faceModel = await FaceLandmarker.createFromOptions(
        vision, options
      );
      
  
    }, 
createCameraElement() {
          this.isLoading = true;
          
          const constraints = (window.constraints = {
                      audio: false,
                      video: true
                  });
          navigator.mediaDevices
              .getUserMedia(constraints)
              .then(stream => {
                  this.isLoading = false;
                  
                  this.myVideo = this.$refs.camera as HTMLVideoElement;
                  this.myCanvas = this.$refs.canvas as HTMLCanvasElement;
                  this.myVideo.srcObject = stream;

                  window.requestAnimationFrame(this.faceMocap);
              });
          },

    faceMocap(){
      {
        const delta = this.clock.getDelta();

        if(this.isCameraOpen && this.myCanvas && this.faceModel){
          const context = this.myCanvas.getContext('2d');
          context?.drawImage(this.myVideo, 0, 0, 200, 150);

          const landmarks = this.faceModel.detectForVideo(this.myVideo, this.videoTimestamp);
          if(landmarks.faceBlendshapes && landmarks.faceBlendshapes[0]){
            let cnt = 0; 
            const target: Category[] = landmarks.faceBlendshapes[0].categories;
            for(const res of target){
              if(typeof this.head.morphTargetDictionary !== 'undefined' && typeof this.head.morphTargetInfluences != 'undefined'){
                const prefix = "";
                // const prefix = "asFaceBS.";
                let index = this.head.morphTargetDictionary[prefix + res.categoryName];
                if(index){
                  this.head.morphTargetInfluences[index] = res.score;
                  cnt += 1;
                }
              }
            
            }
          }
          this.videoTimestamp += Math.round(delta) > 0 ? Math.round(delta) : 1;
          window.requestAnimationFrame(this.faceMocap);
        }
      }
    }, 

@FishWoWater
Copy link

It WORKS using models from this link, taken from this issue

@ArghyaDasIntel
Copy link

@FishWoWater , the latest npm package looks broken. Use the version 0.1.0-alpha-11 instead of "latest" and it should work well. All the best.

@FishWoWater
Copy link

@ArghyaDasIntel Thank you~ Yes, I have tried the 0.1.0-alpha-11 and it works with the model provided by baronda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy:face detection Issues related to Face Detection platform:javascript MediaPipe Javascript issues type:build/install For Build and Installation issues
Projects
None yet
Development

No branches or pull requests

7 participants