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
https://vladmandic.github.io/human/demo/index.html
MIT License
2.39k stars 326 forks source link

Adding a custom model and drawing options #489

Closed anaelshomrai closed 2 months ago

anaelshomrai commented 2 months ago

We are in the process of adding a custom model into Human. Seems like the model is being loaded, running and returning results and I'm now wondering what is the process for being able to draw the results ? similar to the other models.

For integrating the new models, we've followed the steps in here https://github.com/vladmandic/human/wiki/Module

In specific:

  1. Defined the module that overrides the load and predict.
  2. human.ts - Imported the new model and called predict
  3. config.ts - Added our model config options
  4. result.ts - Defined our model results and added to the main Result interface
  5. models.ts - Added our model to the load function

Thank you !

vladmandic commented 2 months ago

nice! if you want to add it to draw:

create a new module in src/draw which exports a draw function with signature for example modelName.ts with

export function modelName(inCanvas: AnyCanvas, result: ObjectResult[], drawOptions?: Partial<DrawOptions>) { }

take a look at object.ts for example.

next add that module to imports section in src/draw/draw.ts and re-export it

import { modelName } from './modelName';
export { modelName} from './modelName';

that's enough that you can now use it using as human.draw.modelName() and if you want it to run automatically along other draw functions, add it to promise loop in function all:

    modelName(inCanvas, result.modelName, localOptions),

i'm closing the issue as its not a product issue, but feel free to continue with conversation here.

anaelshomrai commented 2 months ago

@vladmandic Thank you for the quick response. I've added the relevant methods and it's working.

I'm wondering on a different subject regarding the FPS, is there a way for me to specify the target FPS or even better the target FPS for each model ?

vladmandic commented 2 months ago

per-model? no. globally? its not part of the lib as assumption is that human.detect (or other methods) are called by some other parent app so its really up to parent app to decide how often to call human.