nischi / MMM-Face-Reco-DNN

Face recognition with opencv and deep neural network
MIT License
91 stars 46 forks source link

Multi User not working #130

Closed marivan38 closed 1 year ago

marivan38 commented 1 year ago

Hi I am a complete noob and have been trying to get the multi user working ... I have the datasets created and when I do the encode it seems to work but for the life of me I can not get the users to work... I have added the following

// Array with usernames (copy and paste from training script) //users: ["Ivan","John"], or userClasses: ["Ivan","John"],

then assigned the module to the person { module: 'MMM-GoogleMapsTraffic', classes: "Ivan", position: 'bottom_left', when I run the npm start all I get are the always modules but the ones assigned to the user don't show up. Where am I going wrong

Any help would be greatly appreciated as I love this module so far just can't get that part working.

nischi commented 1 year ago

hi @marivan38 what do you exactly mean with users or userClasses? The config looks fine to me. Do you need to be sure that the case of the class are correct. If the folders a in lower case also the classes need to be in lower case.

Another issue could be that the recognition is not working at all. Have you checked the logs if there is no error and a message like following is there?

[MMM-Face-Reco-DNN] Users Ivan logged in.

marivan38 commented 1 year ago

in my config this is what I have ... module: 'MMM-Face-Reco-DNN', classes: "always default everyone", config: { // Logout 15 seconds after user was not detected any more // If they are detected within this period, the delay will start again logoutDelay: 15000, // How often the recognition starts in milliseconds // With a Raspberry Pi 3+ it works well every 2 seconds checkInterval: 2000, // Module set used for when there is no face detected ie no one is in front of the camera noFaceClass: 'noface', // Module set used for when there is an unknown/unrecognised face detected unknownClass: 'unknown', // Module set used for when there is a known/recognised face detected knownClass: 'known', // Module set used for strangers and if no user is detected defaultClass: 'default', // Set of modules which should be shown for any user ie when there is any face detected everyoneClass: 'everyone', // Set of modules that are always shown - show if there is a face or no face detected alwaysClass: 'always', // users users: [ "Ivan", "John"], ==> Do I even need this?

Also the name cases all start with Caps I have tried with and without caps as well no luck ....

now that your mentioning it the recognition see's me then logs me out very quickly so maybe my image is not good ... I will also check the logs and see if there is anything like that message in there and get back and let you know. Thanks for the help

marivan38 commented 1 year ago

So I just looked at the logs I see the following...

11.02.2023 15:49.44.834] [LOG] [MMM-Face-Reco-DNN] loading encodings + face detector... [11.02.2023 15:49.44.973] [LOG] [MMM-Face-Reco-DNN] starting video stream... [11.02.2023 15:50.16.745] [LOG] [MMM-Face-Reco-DNN] Users Ivan logged in. [11.02.2023 15:50.19.715] [LOG] [MMM-Face-Reco-DNN] Users Ivan logged out. [1080:0211/155116.463706:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 3 times! [11.02.2023 15:51.31.926] [LOG] [MMM-Face-Reco-DNN] Users Ivan logged in. [11.02.2023 15:51.34.898] [LOG] [MMM-Face-Reco-DNN] Users Ivan logged out.

it seems to log me in and log me out very quickly but i am getting recognized I will try another person and see if the same thing is happening... is there anything else that I can check or verify?

nischi commented 1 year ago

in my config this is what I have ... module: 'MMM-Face-Reco-DNN', classes: "always default everyone", config: { // Logout 15 seconds after user was not detected any more // If they are detected within this period, the delay will start again logoutDelay: 15000, // How often the recognition starts in milliseconds // With a Raspberry Pi 3+ it works well every 2 seconds checkInterval: 2000, // Module set used for when there is no face detected ie no one is in front of the camera noFaceClass: 'noface', // Module set used for when there is an unknown/unrecognised face detected unknownClass: 'unknown', // Module set used for when there is a known/recognised face detected knownClass: 'known', // Module set used for strangers and if no user is detected defaultClass: 'default', // Set of modules which should be shown for any user ie when there is any face detected everyoneClass: 'everyone', // Set of modules that are always shown - show if there is a face or no face detected alwaysClass: 'always', // users users: [ "Ivan", "John"], ==> Do I even need this?

Also the name cases all start with Caps I have tried with and without caps as well no luck ....

now that your mentioning it the recognition see's me then logs me out very quickly so maybe my image is not good ... I will also check the logs and see if there is anything like that message in there and get back and let you know. Thanks for the help

no the users is no setting from my module.

it's strange that you will logged out so quickly, because the logout delay is 15000 seconds. do you have any errors in the logs?

marivan38 commented 1 year ago

Good day and before I start just wanted to say thank you for all your help... I am uploading some screen captures that I took from the debug window ... Also I am not sure if the recognition program is working right as for some reason it is seeing users that are not even in front of the camera... I also did not see anything that stand out at me in /var/log/messages

image2 image1 image0

marivan38 commented 1 year ago

Maybe I should also ask another question since I am a noob ... if I want to have for example mMM-globe only when the face is unknown/nobody/faceless what should I set the (classess:"") too?

nischi commented 1 year ago

Maybe I should also ask another question since I am a noob ... if I want to have for example mMM-globe only when the face is unknown/nobody/faceless what should I set the (classess:"") too?

simple question first :) noface

nischi commented 1 year ago

Good day and before I start just wanted to say thank you for all your help... I am uploading some screen captures that I took from the debug window ... Also I am not sure if the recognition program is working right as for some reason it is seeing users that are not even in front of the camera... I also did not see anything that stand out at me in /var/log/messages

hmm i do not see anything crazy. It seems a little bit like he recognized you twice. Maybe this make some issues. Can you please send me the full config of my module?

and have you tried to reduce your config for example only to one simple module? For example the clock. That you can be sure it's not another module which make some problems.

marivan38 commented 1 year ago

{ module: 'MMM-Globe', classes: "noface", position: 'middle_center', config: { style: 'geoColor', imageSize: 600, ownImagePath:'', updateInterval: 10601000 } }, { module: 'MMM-SmartTouch', classes: "always default", position: 'bottom_center', // This can be any of the regions.(bottom-center Recommended) config:{ // None configuration options defined } }, { module: 'MMM-ProfileSwitcher', //classes: "always default everyone", config: { // See 'Configuration options' for more information. everyoneClass: "everyone", includeEveryoneToDefault: "true", ignoreModules: ['MMM-ProfileSwitcher', 'MMM-Faces'], } }, { module: 'MMM-page-indicator', classes: "everyone", position: 'bottom_bar', config: { pages: 3, } }, { module: 'MMM-Face-Reco-DNN', //classes: "always ", config: { // Logout 15 seconds after user was not detected any more // If they are detected within this period, the delay will start again logoutDelay: 15000, // How often the recognition starts in milliseconds // With a Raspberry Pi 3+ it works well every 2 seconds checkInterval: 2000, // Module set used for when there is no face detected ie no one is in front of the camera noFaceClass: 'noface', // Module set used for when there is an unknown/unrecognised face detected unknownClass: 'unknown', // Module set used for when there is a known/recognised face detected knownClass: 'known', // Module set used for strangers and if no user is detected defaultClass: 'default', // Set of modules which should be shown for any user ie when there is any face detected everyoneClass: 'everyone', // Set of modules that are always shown - show if there is a face or no face detected alwaysClass: 'always', // Array with usernames (copy and paste from training script) //users: ["Ivan","Theresa","Elijah","Josais","Taj","CynthiaD"], //userClasses: ["Ivan","Theresa","Elijah","Josais","Taj","CynthiaD"], // XML to recognize with haarcascade cascade: 'modules/MMM-Face-Reco-DNN/tools/haarcascade_frontalface_default.xml', // Pre-encoded pickle with the faces encodings: 'modules/MMM-Face-Reco-DNN/tools/encodings.pickle', // Use Raspberry Pi camera or another type // 1 = RasPi camera, 0 = other camera usePiCamera: 1, // Brightness, negative is darker, positive is brighter brightness: 0, // Contrast, positive value for more contrast contrast: 0, // If using another type of camera, you can choose // i.e. 0 = /dev/video0 or 'http://link.to/live' source: 0, // Rotate camera rotateCamera: 0, // Method of facial recognition // dnn = deep neural network, haar = haarcascade method: 'dnn', // Which face detection model to use // "hog" is less accurate but faster on CPUs // "cnn" is a more accurate deep-learning model which is GPU/CUDA accelerated detectionMethod: 'hog', // How long in milliseconds modules take to hide and show animationSpeed: 0, // Path to Python to run the face recognition // null or '' means default path pythonPath: null, // Should a welcome message be shown using the MagicMirror alerts module? welcomeMessage: true, // Dictionary for person name mapping in welcome message // Allows for displaying name with complex character sets in welcome message e.g. jerome => Jérôme, hideyuki => 英之 usernameDisplayMapping: null, // Capture new pictures of recognized people, if unknown we save it in folder "unknown" // So you can extend your dataset and retrain it afterwards for better recognitions extendDataset: false, // If extendDataset is true, you need to set the full path of the dataset dataset: 'modules/MMM-Face-Reco-DNN/dataset/', // How much distance between faces to consider it a match. Lower is more strict. tolerance: 0.6, // allow multiple concurrent user logins, 0=no, any other number is the maximum number of concurrent logins multiUser: 0, debug: true, } }, { module: "MMM-Face-Multi-User-Recognition-SMAI", classes: "always everyone", position: "bottom_right", config: { useMMMFaceRecoDNN: true } },

marivan38 commented 1 year ago

I am currently disabling modules and trying it one step at a time to see if there is something that I am missing or conflicting for not the major ones I wanted working are the face-reco , youtube and globe as far as i see they should work together ..

nischi commented 1 year ago

strange, i do not see anything wrong with the config.

marivan38 commented 1 year ago

Hi Nischi, Thanks for all your help for some reason the OS got corrupted and I had to start all over again... This time I started off with your module and added and added and added :-) .. now it seems to be working fine I am thinking that I must have missed something on the install or corrupted something along the way.

nischi commented 1 year ago

okay :) nice to hear that it was not my module :)