vladmandic / human

Human: AI-powered 3D Face Detection & Rotation Tracking, Face Description & Recognition, Body Pose Tracking, 3D Hand & Finger Tracking, Iris Analysis, Age & Gender & Emotion Prediction, Gaze Tracking, Gesture Recognition

Home Page:https://vladmandic.github.io/human/demo/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to destroy human cache?

Relsoul opened this issue · comments

commented

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

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.