oarriaga / face_classification

Real-time face detection and emotion/gender classification using fer2013/imdb datasets with a keras CNN model and openCV.
MIT License
5.58k stars 1.59k forks source link

A problem when running "image_gradcam_demo.py" #48

Closed ustczeng closed 6 years ago

ustczeng commented 6 years ago

Traceback (most recent call last): File "image_gradcam_demo.py", line 73, in predicted_class, 'conv2d_7') File "/home/zengyiqi/project/face_classification/src/utils/grad_cam.py", line 115, in compile_gradient_function gradients = normalize(K.gradients(loss, conv_output)[0]) File "/home/zengyiqi/project/face_classification/src/utils/grad_cam.py", line 31, in normalize return x / (K.sqrt(K.mean(K.square(x))) + 1e-5) File "/home/zengyiqi/anaconda2/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 1417, in square return tf.square(x) File "/home/zengyiqi/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 449, in square return gen_math_ops.square(x, name=name) File "/home/zengyiqi/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/gen_math_ops.py", line 4567, in square "Square", x=x, name=name) File "/home/zengyiqi/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 528, in _apply_op_helper (input_name, err)) ValueError: Tried to convert 'x' to a tensor and failed. Error: None values not supported.

when I ran the commad of "python image_gradcam_demo.py ../images/test_image.jpg", there is a problem with the errer log above. How can I solve this problem? I would appreciate it very much if you could help me!

ustczeng commented 6 years ago

@oarriaga Have you met with this problem?

mirceaciu commented 6 years ago

I've run the same command, the script run without errors and created '../images/guided_gradCAM.png'.

You might have compatibility issues between Tensorflow and Keras. This might help.

ustczeng commented 6 years ago

@mirceaciu Thank you very much! That is the problem of the version of keras. I change keras 2.1.2 back to 2.0.5. This method solve the problem.