nischi / MMM-Face-Reco-DNN

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

PythonShellError: AttributeError: 'NoneType' object has no attribute 'shape' #63

Closed ChrizZz90 closed 3 years ago

ChrizZz90 commented 3 years ago

I receive an error in the pm2 logs:

` [2020-09-06 15:14:07.898] [ERROR] Whoops! There was an uncaught exception... [2020-09-06 15:14:07.901] [ERROR] PythonShellError: AttributeError: 'NoneType' object has no attribute 'shape' 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. (/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 106, in <module>
  frame = imutils.resize(originalFrame, width=500)
File "/usr/local/lib/python3.7/dist-packages/imutils/convenience.py", line 69, in resize
  (h, w) = image.shape[:2] {

traceback: 'Traceback (most recent call last):\n File ' + '"modules/MMM-Face-Reco-DNN/tools/facerecognition.py", line 106, in ' + '\n frame = imutils.resize(originalFrame, width=500)\n File ' + '"/usr/local/lib/python3.7/dist-packages/imutils/convenience.py", line ' + "69, in resize\n (h, w) = image.shape[:2]\nAttributeError: 'NoneType' " + "object has no attribute 'shape'\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=0', '--source=0', '--rotateCamera=0', '--method=dnn', '--detectionMethod=hog', '--interval=2000', '--output=0', '--extendDataset=True', '--dataset=modules/MMM-Face-Reco-DNN/dataset/', '--tolerance=0.6' ], exitCode: 1 } `

Everything is up to date. My config:

{ module: 'MMM-Face-Reco-DNN', config: { // Logout 30 seconds after user was not detecte anymore, if they will be detected between this 30 Seconds, they delay will start again logoutDelay: 30000, // How many time the recognition starts, with a RasPi 3+ it would be good 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 every user everyoneClass: 'everyone', // Set of modules that are always shown - show if there is a face or no face detected alwaysClass: 'always', // XML to recognize with haarcascae 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', // You wanna use pi camera or usb / builtin (1 = raspi camera, 0 = other camera) usePiCamera: 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 face detection (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 (if available). detectionMethod: 'hog', // How fast in ms should the modules hide and show (face effect) animationSpeed: 0, // Path to Python to run the face recognition (null / '' means default path) pythonPath: null, // Should shown welcome message over alert module from MagicMirror welcomeMessage: true, // Save some pictures from recognized people, if unknown we save it in folder "unknown" // So you can extend your dataset and retrain it afterwards for better recognitions extendDataset: true, // 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, 1=yes multiUser: 0, } },