npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nuralogix.ai/awc-tfjs-face-tracker

v1.0.0

Published

Anura Web Core TensorFlow.js Face Tracker Plugin

Downloads

5

Readme

Anura Web Core TensorFlow.js Face Tracker Plugin

Description

The library is designed to work as a face tracker plugin for Anura Web Core. It is a wrapper around Tensorflow.js face tracker and is intended to mask any complexities involved in configuring face trackers separately. It can simply either be used as a plugable face tracker for Anura Web Core or as a stand-alone Deepaffex™ compatible face tracker.

Installation

The main way that we ship Anura Web Core TensorFlow.js Face Tracker Plugin code to NPM is as ECMAScript modules with ECMAScript 2022, the 13th edition syntax. This allows developers to take advantage of modern JavaScript features and have greater control over what they ship to their end users.

You can use either of the following methods to add the library to your project:

Package managers

# yarn
yarn add @nuralogix.ai/awc-tfjs-face-tracker

# npm
npm install @nuralogix.ai/awc-tfjs-face-tracker

Script tag

You can load them from popular CDNs such as skypack, JsDelivr and Unpkg.

<html>
  <body>
    <script type="module">
        import * as tfjs from 'https://cdn.skypack.dev/@nuralogix.ai/[email protected]';
        // .
        // The rest of your code
        // .
        // .
        // Let's assume that you have already imported ImageSource
        imageSource = new ImageSource({
            // Other Anura Web Core config object(s)...
            faceTracker: { worker: tfjs, options: {} } }
        });
    </script>
  </body>
</html>

Stand-alone Deepaffex™ compatible Face Tracker

If you would like to use this library without using Anura Web Core

<html>
  <body>
    <script type="module">
        import { workerCode } from 'https://cdn.skypack.dev/@nuralogix.ai/[email protected]';
        const blob = new Blob([workerCode], { type: 'text/javascript' });
        const options = {'TfjsFaceTracker', type: 'module'};
        const worker = new Worker(
            new URL(URL.createObjectURL(blob), import.meta.url),
            options
        );
        // Initalize the worker
        worker.postMessage(['INIT', {}]);
        // hanlde messages received from the worker
        worker.onmessage = (e) => {
            const [action, data] = e.data;
            if (data) {
                if (action === 'READY') {
                    // When the worker is ready
                    console.log('READY', 'version', data);
                }
                if (action === 'WARMED_UP') {
                    // The time of first call to face tracker also includes the compilation time
                    // of WebGL shader programs for the model.
                    // After the first call the shader programs are cached,
                    // which makes the subsequent calls much faster.
                    console.log('WARMED_UP', data.success, data.timestamp);
                }
                if (action === 'MESSAGE') {
                    // Any log, info or error message
                    console.log('MESSAGE', data);
                }
                if (action === 'FT_READY_NEXT_FRAME') {
                    // isReady and timestamp show if face tracker is ready
                    // to accept new frames
                    console.log('FT_READY_NEXT_FRAME', data.isReady, data.timestamp);
                }          
                if (action === 'FACIAL_LANDMARKS') {
                    // When the images is processed and the facial landmarks are available
                    console.log('FACIAL_LANDMARKS', data);
                }
                if (action === 'DESTROYED') {
                    // When the worker received a destroy action
                    console.log('DESTROYED', data);
                    worker.terminate();
                    URL.revokeObjectURL(worker);
                }
            }
        }
        // Suppose that we already have an ImageData and you want to pass it to worker
        // for processing
        const nextFrame = {
          height: imageData.height,
          width: imageData.width,
          buffer: imageData.data.buffer,
          timestamp_ms,
          frameNumber: metadata.presentedFrames,
        }
        worker.postMessage(['GET_FACIAL_LANDMARKS', nextFrame], [nextFrame.buffer]);

        // If you want to destroy the worker:
        // If you pass an optional string then it will be return on DESTROYED event
        // This is useful when you have multiple intances of the worker and what to
        // distinguish them by an ID 
        worker.postMessage(['DESTROY', 'optional-string']);
    </script>
  </body>
</html>