Git Product home page Git Product logo

Comments (3)

ziyuan-linn avatar ziyuan-linn commented on June 18, 2024 1

Upon further investigation, it appears that the issue is caused by mediapipe runtime. I experimented using tfjs runtime using the code below and the error went away.

preload() {
  handpose = ml5.handpose({ runtime: "tfjs" });
  facemesh = ml5.facemesh({ runtime: "tfjs" });
}

I came across this thread on the mediapipe repo discussing a similar issue. The suggested solution involves loading the models one by one.

"currently the initializers don't play nicely together. But you shouldn't need anything complicated-- just adding await before the .initialize() calls (specifically await selfieSegmentation.initialize()) should be sufficient."

One potential solution for us is to implement a queue within ml5 for model initialization calls using the mediapipe runtime. This queue would handle the loading of models one by one in a synchronous manner.

I'd appreciate any thoughts or further insights.

from ml5-next-gen.

alanvww avatar alanvww commented on June 18, 2024

I recently worked on a project and encountered the same problem. I didn't notice that this can be solved by switching to another runtime, but here is my solution:

async function modelLoader() {
  // Create a function that returns a promise for loading faceMesh
  const loadFaceMesh = () =>
    new Promise((resolve) => {
      faceMesh = ml5.faceMesh(options, () => {
        console.log("faceMesh loaded");
        resolve();
      });
    });

  // Create a function that returns a promise for loading handPose
  const loadHandPose = () =>
    new Promise((resolve) => {
      handPose = ml5.handPose({ maxHands: 20 }, () => {
        console.log("handPose loaded");
        resolve();
      });
    });

  // Await the promises in sequence to ensure proper order of execution
  await loadFaceMesh();
  await loadHandPose();
}

function preload() {
  modelLoader();
}

I would definitely like to see if the library itself can have some built-in logic for solving this problem.

from ml5-next-gen.

eyaler avatar eyaler commented on June 18, 2024

small typo in:

let handpose;
let facemesh;
preload() {
  handpose = ml5.handpose(() => {
    facemesh = ml5.facemesh();
  });
}

should be:

preload() {
  handpose = ml5.handPose(() => {
    facemesh = ml5.faceMesh();
  });
}  

from ml5-next-gen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.