Comments (5)
Hi @davepagurek thank you for reporting this and for your patience! I am working adding some documentation to this repo and archiving it. We have moved current ml5.js development to a new repository:
https://github.com/ml5js/ml5-next-gen
The latest examples are here:
https://editor.p5js.org/ml5/collections/pUzWMkdmE
We are planning to launch a new version of the library + website in June.
The new BodyPose
functionality of ml5.js uses updated models behind the scenes (MoveNet
and BlazePose
). @ziyuan-linn have you noticed any signs of a memory leak like this in our newer examples?
from ml5-next-gen.
Just skimming the code, it looks like the looping pattern here https://github.com/ml5js/ml5-next-gen/blob/main/src%2FBodyPose%2Findex.js#L312 would avoid the issue since it doesn't return the result of the promise, but I can try profiling the examples when I get back to my computer to be sure.
from ml5-next-gen.
I was testing out this one https://editor.p5js.org/ml5/sketches/OukJYAJAb and taking heap snapshots every few minutes, and the snapshots seem to increase in size over time:
![image](https://private-user-images.githubusercontent.com/5315059/327932895-0bbabfcb-7578-424a-b76d-d60ddb24c798.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE3MDMzMzIsIm5iZiI6MTcyMTcwMzAzMiwicGF0aCI6Ii81MzE1MDU5LzMyNzkzMjg5NS0wYmJhYmZjYi03NTc4LTQyNGEtYjc2ZC1kNjBkZGIyNGM3OTgucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcyMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MjNUMDI1MDMyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MjY5OGZjNTc0YTk5ODY1ZDRhZTE1YjMxNDQ3MTMwMjY5YzgwNTgwMjg5MTk2ZThmYmZmOTdhN2YwNzE4OTY2ZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.uOtPj3P1a6zhazchdBC5yLxxP_IyrvImHbTPYcZ8gzk)
So that might mean there's a leak somewhere still? Here's the first and last snapshot for comparison:
BEFORE-Heap-20240504T094341.heapsnapshot.zip
AFTER-Heap-20240504T094350.heapsnapshot.zip
I see something kind of similar going on in the added Object
s. They don't appear as promises this time, but the last one in the chain does say "pending."
from ml5-next-gen.
Thanks @davepagurek I moved this issue into the current repo for further discussion and tracking!
from ml5-next-gen.
@davepagurek Thank you for reporting this issue!
I did some testing and found memory leaks in a few models. Here are the heap snapshots:
bodyPose
, with MoveNet
as the underlying model:
bodyPose
, with BlazePose
as the underlying model on mediapipe
runtime:
faceMesh
, on mediapipe
runtime:
This problem only seems to occur when using the mediapipe
runtime. I think the problem could be due to MediaPipe using WASM and C++(no automatic garbage collection). Even this tfjs demo of face-landmark-detection on MediaPipe runtime have a memory leak. I could not find much information about this, but here is a potentially related issue with a solution.
For now, switching to tfjs
runtime or MoveNet
on the new version of ml5 should fix the memory leak:
bodyPose = ml5.bodyPose("BlazePose", { runtime: "tfjs" });
or
bodyPose = ml5.bodyPose("MoveNet");
from ml5-next-gen.
Related Issues (20)
- 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 HOT 2
- Making `tfjs` runtime the default HOT 2
- faceMesh custom shape
- add smoothing to BlazePose under `tfjs` HOT 2
- Question about `maskType` HOT 6
- Google search for reference leads to a non existing page HOT 2
- Posenet Model Does Not Load Suddenly HOT 2
- featureExtractor() not working HOT 1
- Uncaught (in promise) TypeError: ml5.flipImage is not a function HOT 1
- TypeError: ml5.objectDetector is not a function HOT 1
- `topk` in the `options` for `imageClassifier` doesn't work HOT 2
- Errors with ml5.js code (from prior to 1.0 release)!
- Configure issue template for ml5-next-gen repo HOT 1
- Use "good first issue" label on issues and add to contributing documentation HOT 1
- Specify version for yarn and node HOT 4
- Code and comment cleanup
- `bodyPose` and `bodySegmentation` failing to preload in p5 instance mode 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.