Comments (3)
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 (specificallyawait 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.
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.
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)
- What happened to the "skeleton" part of the `bodyPose`? HOT 4
- `bodyPose` bounding box coordinates are in the 0-1 range HOT 1
- CDN for ml5.js release HOT 8
- Error in neuralNetrwork "mouse gesture" example if you click without dragging
- Question about Neural Network normalization HOT 2
- Error installing dependencies HOT 7
- Another alpha release? HOT 6
- Testing new p5 mirror function HOT 5
- `faceMesh` lips missing `keypoint` 291 HOT 3
- Discussion: `NeuralNetwork`
- README references and examples page? HOT 1
- setBackend() required for ml5.neuralNetwork() bug HOT 4
- ml5 file size HOT 5
- Memory leak in PoseNet's video processing pattern HOT 5
- make api compatible with code using legacy library HOT 1
- why pose keypoints x and y positions will misalign the video stream whenever the video size is not (640, 480) HOT 1
- `confidence` vs `score` across all models HOT 2
- Minor errors in documentation.md HOT 1
- Incorporating "flipped" property
- Making `tfjs` runtime the default HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ml5-next-gen.