How to destroy human cache?
Relsoul opened this issue · comments
Issue Description
For some reason, I have to initialize human repeatedly. The cache memory of the previous human will not be freed after repeated initialization
I find it helpful to set cacheSensitivity to 0. Is there a way to free the cache?
Steps to Reproduce
// init function
const human = new Human({
// add any custom config here
debug: false,
// videoOptimized: false,
modelBasePath: 'file://assets/model',
face: {
enabled: true,
detector: {
enabled: true,
maxDetected: 1,
minConfidence: 0.61,
rotation: false,
},
mesh: { enabled: true },
description: { enabled: true },
emotion: { enabled: true },
antispoof: { enabled: true }, // enable optional antispoof module
liveness: { enabled: true },
},
body: {
enabled: true,
minConfidence: 0.23,
},
// object: { enabled: true },
hand: {
enabled: false,
},
});
await human.init();
return human;
// test.js
for(let i of [1,2,3,4,5,6,7,8,9,10]){
const human = await init()
// do detect
let result;
try {
result = await human.detect(tensor); // run detection; will initialize backend and on-demand load models
} catch (e) {
human.tf.dispose(tensor);
buffer = null;
human = null;
throw new Error(e);
}
// free mem
human.tf.dispose(tensor);
buffer = null;
human = null; // The cache is not released...
}
// Memory will keep going up
Expected Behavior
Environment
- Human library version?
3.0.1
-
Built-in demo or custom code?
-
Type of module used (e.g.
js
,esm
,esm-nobundle
)? -
TensorFlow/JS version (if not using bundled module)?
4.1.0
- Browser or NodeJS and version (e.g. NodeJS 14.15 or Chrome 89)?
16.18.1
- OS and Hardware platform (e.g. Windows 10, Ubuntu Linux on x64, Android 10)?
macos m2 13.4.1 / ubuntu 20
-
Packager (if any) (e.g, webpack, rollup, parcel, esbuild, etc.)?
-
Framework (if any) (e.g. React, NextJS, etc.)?
nest.js
Diagnostics
- Check out any applicable diagnostic steps
Additional
- For installation or startup issues include your
package.json
- For usage issues, it is recommended to post your code as gist
- For general questions, create a discussion topic
that's not cache. you're trying to unload entire module and that module also includes tfjs. javascript is not indented to be used that way. i don't know what you're even trying to do, but this is not the way.