Read the statement by Michael Teeuw here.
MMM-Face-Reco-DNN receiving PythonShellError: TypeError
-
I am trying to get facial recognition working but it is not happening. Here is what I have found. Any advice on how to get this to work?
I have loaded the MMM-Face-Reco-DNN and even used the i_face_recognition.py from https://www.pyimagesearch.com/2018/06/25/raspberry-pi-face-recognition/ with the encodings file generated from the MMM-Face-Reco-DNN instructions and had that .py file recognize faces. So I backed everything out of my config file except the default MMM-Face-Reco-DNN settings from the instructions and when I manually start MM2 everything looks fine. I am running on a Raspberry Pi 4. I did install a different facial recognition module, but it was not in the config file and decided not to use it when I saw it only recognized 1 person. When I step in front of the camera, this comes up in the terminal where I manually started MM2:
[2020-08-09 00:59:28.399] [ERROR] Whoops! There was an uncaught exception... [2020-08-09 00:59:28.400] [ERROR] PythonShellError: TypeError: '<' not supported between instances of 'numpy.ndarray' and 'str' at PythonShell.parseError (/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:246:21) at terminateIfNeeded (/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:129:32) at ChildProcess.<anonymous> (/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:121:13) at ChildProcess.emit (events.js:200:13) at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12) ----- Python Traceback ----- File "modules/MMM-Face-Reco-DNN/tools/facerecognition.py", line 143, in <module> if minDistance < args["tolerance"]: { traceback: 'Traceback (most recent call last):\n File ' + '"modules/MMM-Face-Reco-DNN/tools/facerecognition.py", line ' + '143, in <module>\n if minDistance < args["tolerance"]:\n' + "TypeError: '< ' not supported between instances of " + "'numpy.ndarray' and 'str'\n", executable: 'python3', options: null, script: 'modules/MMM-Face-Reco-DNN/tools/facerecognition.py', args: [ '--cascade=modules/MMM-Face-Reco-DNN/tools/haarcascade_frontalface_default.xml', '--encodings=modules/MMM-Face-Reco-DNN/tools/encodings.pickle', '--usePiCamera=1', '--source=0', '--rotateCamera=0', '--method=dnn', '--detectionMethod=hog', '--interval=2000', '--output=0', '--extendDataset=False', '--dataset=modules/MMM-Face-Reco-DNN/dataset/', '--tolerance=0.6' ], exitCode: 1 } [2020-08-09 00:59:28.409] [ERROR] MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection? [2020-08-09 00:59:28.409] [ERROR] If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues
Here is my config.js
/* Magic Mirror Config Sample * * By Michael Teeuw https://michaelteeuw.nl * MIT Licensed. * * For more information on how you can configure this file * See https://github.com/MichMich/MagicMirror#configuration * */ var config = { address: "0.0.0.0", port: 8080, basePath: "/", // The URL path where MagicMirror is hosted. If you are using a Reverse proxy // you must set the sub path here. basePath must end with a / ipWhitelist: [], useHttps: false, // Support HTTPS or not, default "false" will use HTTP httpsPrivateKey: "", // HTTPS private key path, only require when useHttps is true httpsCertificate: "", // HTTPS Certificate path, only require when useHttps is true language: "en", logLevel: ["INFO", "LOG", "WARN", "ERROR"], timeFormat: 12, units: "imperial", // serverOnly: true/false/"local" , // local for armv6l processors, default // starts serveronly and then starts chrome browser // false, default for all NON-armv6l devices // true, force serveronly mode, because you want to.. no UI on this device modules: [ { module: "alert", classes: 'default everyone', }, { module: "updatenotification", classes: 'default everyone', position: "top_bar" }, { module: "clock", classes: 'default everyone', position: "top_left" }, { module: 'MMM-Face-Reco-DNN', 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 strangers or if no user is detected defaultClass: 'default', // Set of modules which should be shown for every recognised user everyoneClass: 'everyone', // 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, // 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, // 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 } }, ] }; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") {module.exports = config;}
And here is everything in the terminal before stepping in front of the camera:
pi@raspberrypi:~/MagicMirror $ npm start > magicmirror@2.12.0 start /home/pi/MagicMirror > DISPLAY="${DISPLAY:=:0}" ./node_modules/.bin/electron js/electron.js [2020-08-09 00:58:21.215] [LOG] Starting MagicMirror: v2.12.0 [2020-08-09 00:58:21.240] [LOG] Loading config ... [2020-08-09 00:58:21.248] [LOG] Loading module helpers ... [2020-08-09 00:58:21.251] [LOG] No helper found for module: alert. [2020-08-09 00:58:21.325] [LOG] Initializing new module helper ... [2020-08-09 00:58:21.326] [LOG] Module helper loaded: updatenotification [2020-08-09 00:58:21.328] [LOG] No helper found for module: clock. [2020-08-09 00:58:21.354] [LOG] Initializing new module helper ... [2020-08-09 00:58:21.355] [LOG] Module helper loaded: MMM-Face-Reco-DNN [2020-08-09 00:58:21.355] [LOG] All module helpers loaded. [2020-08-09 00:58:21.566] [LOG] Starting server on port 8080 ... [2020-08-09 00:58:21.574] [INFO] You're using a full whitelist configuration to allow for all IPs [2020-08-09 00:58:21.580] [LOG] Server started ... [2020-08-09 00:58:21.581] [LOG] Connecting socket for: updatenotification [2020-08-09 00:58:21.583] [LOG] Connecting socket for: MMM-Face-Reco-DNN [2020-08-09 00:58:21.583] [LOG] Starting module helper: MMM-Face-Reco-DNN [2020-08-09 00:58:21.584] [LOG] Sockets connected & modules started ... [2020-08-09 00:58:21.891] [LOG] Launching application. [2020-08-09 00:58:25.058] [INFO] Checking git for module: MMM-Face-Reco-DNN [2020-08-09 00:58:32.928] [LOG] [MMM-Face-Reco-DNN] loading encodings + face detector... [2020-08-09 00:58:33.177] [LOG] [MMM-Face-Reco-DNN] starting video stream...
-
@KSumwalt it seems that python has added type checking, which it wasn’t using before.
there was another python related type checking problem a few days ago…
looks like the node_helper has launched the python script to compare the face files, and run into a problem checking the parms passed to it.
-
@sdetweil Thank you. I have passed this on as an issue on the github site for the plugin.
-
@KSumwalt , hi! Check the module update.
-
Beautiful! I updated and it appears to be working fine. Thank you, @x3mEr !!!