atulapra / Emotion-detection

Real-time Facial Emotion Detection using deep learning
MIT License
1.19k stars 488 forks source link

Name 'cascade_classifier' is not defined? #9

Closed Dentrax closed 5 years ago

Dentrax commented 5 years ago

I'm getting this error when i run program with: python model.py singleface

File structure:

./
├── __pycache__/
│  ├── model.cpython-36.pyc
│  └── singleface.cpython-36.pyc
├── Data/
├── emojis/
│  ├── angry.png
│  ├── disgusted.png
│  ├── fearful.png
│  ├── happy.png
│  ├── neutral.png
│  ├── sad.png
│  └── surprised.png
├── Data.tar.gz
├── haarcascade_frontalface_default.xml
├── model.py
├── model_1_atul.tflearn.data-00000-of-00001
├── model_1_atul.tflearn.index
├── model_1_atul.tflearn.meta
├── multiface.py
└── singleface.py

Full Traceback:

------------Emotion Detection Program------------

Input data      (48, 48, 1)
WARNING:tensorflow:From /home/dentrax/Projects/GitHub/emotion-recognition-neural-networks/lib/python3.6/site-packages/tflearn/initializations.py:119: UniformUnitScaling.__init__ (from tensorflow.python.ops.init_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.initializers.variance_scaling instead with distribution=uniform to get equivalent behavior.
Conv1           (48, 48, 64)
Maxpool1        (24, 24, 64)
Conv2           (24, 24, 64)
Maxpool2        (12, 12, 64)
Conv3           (12, 12, 128)
Dropout         (12, 12, 128)
Fully connected (3072,)
Output          (7,)
WARNING:tensorflow:From /home/dentrax/Projects/GitHub/emotion-recognition-neural-networks/lib/python3.6/site-packages/tflearn/objectives.py:66: calling reduce_sum (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version.
Instructions for updating:
keep_dims is deprecated, use keepdims instead
2019-01-20 22:18:54.042648: E tensorflow/stream_executor/cuda/cuda_driver.cc:300] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
Traceback (most recent call last):
  File "model.py", line 75, in <module>
    import singleface
  File "/home/dentrax/Projects/GitHub/Emotion-detection/TFLearn/singleface.py", line 66, in <module>
    result = network.predict(format_image(frame))
  File "/home/dentrax/Projects/GitHub/Emotion-detection/TFLearn/singleface.py", line 22, in format_image
    faces = cascade_classifier.detectMultiScale(image,scaleFactor = 1.3 ,minNeighbors = 5)
NameError: name 'cascade_classifier' is not defined
Dentrax commented 5 years ago

FIX:

Please add this line to singleface.py in line #21

cascade_classifier = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')

P.S: I'm sorry I didn't send PR

atulapra commented 5 years ago

Thanks for pointing this out. It will be fixed.

pranavspawar commented 2 years ago

cascade_classifier = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') what is meaning of this line . Can you explain pleases?