jeeliz / jeelizFaceFilter

Javascript/WebGL lightweight face tracking library designed for augmented reality webcam filters. Features : multiple faces detection, rotation, mouth opening. Various integration examples are provided (Three.js, Babylon.js, FaceSwap, Canvas2D, CSS3D...).
https://jeeliz.com
Apache License 2.0
2.71k stars 535 forks source link

Changing the neural net throws error at runtime #308

Closed marcusx2 closed 1 year ago

marcusx2 commented 1 year ago

If you get the threejs cube example, and change the _initfaceFilter function to

function init_faceFilter(videoSettings){
  JEELIZFACEFILTER.init({
    followZRot: true,
    canvasId: 'jeeFaceFilterCanvas',
    NNCPath: 'NN_LIGHT_1.json', // root of NN_DEFAULT.json file
    maxFacesDetected: 1,
    callbackReady: async function(errCode, spec){
      if (errCode){
        console.log('AN ERROR HAPPENS. ERR =', errCode);
        return;
      }

      await JEELIZFACEFILTER.destroy();

        JEELIZFACEFILTER.init({
            followZRot: true,
            canvasId: 'jeeFaceFilterCanvas',
            NNCPath: 'NN_4EXPR_2.json', // root of NN_DEFAULT.json file
            maxFacesDetected: 1,
            callbackReady: function (errCode, spec) {
                if (errCode) {
                    console.log('AN ERROR HAPPENS. ERR =', errCode);
                    return;
                }

            },

            // called at each render iteration (drawing loop):
            callbackTrack: function (detectState) {
                JeelizThreeHelper.render(detectState, THREECAMERA);
            }
        }); //end JEELIZFACEFILTER.init call

    },

    // called at each render iteration (drawing loop):
    callbackTrack: function(detectState){
      JeelizThreeHelper.render(detectState, THREECAMERA);
    }
  }); //end JEELIZFACEFILTER.init call
}

so that it is first initialized with the _NN_LIGHT1 neural network, but later changed to _NN_4EXPR2 (I destroy and init again), you will get the following error on the console (give it a few seconds)

image
xavierjs commented 1 year ago

Hi @marcusx2 Thank you for this detailed bug report. I was able to reproduce it and I it should be fixed by the last commit.

marcusx2 commented 1 year ago

Thanks that worked!

xavierjs commented 1 year ago

@marcusx2 Hi Marcus

When you do something very cool like a Unity plugin for Jeeliz Facefilter, feel free to tell it :) ! I just did a bit of advertisement:

marcusx2 commented 1 year ago

Hi @xavierjs

When you do something very cool like a Unity plugin for Jeeliz Facefilter, feel free to tell it :) !

I did! I linked to your jeeliz website and this repo

image

Thanks for the advertisement!

xavierjs commented 1 year ago

Hi @marcusx2

Sure I noticed the link thanx, by feel free to tell it I did not mean to add the jeeliz facefilter link but just to tell informally, I am always glad to test and post stuff about stuff made using Jeeliz or WebAR.rocks libs.