Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: list index out of range (input_shape) #52

Closed
maisen20 opened this issue Jun 20, 2020 · 8 comments
Closed

IndexError: list index out of range (input_shape) #52

maisen20 opened this issue Jun 20, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@maisen20
Copy link

maisen20 commented Jun 20, 2020

Hi and thank you for your work.

Unfortunately, it's not working for me. If I want to run the test, I get the output below. Somehow it seems to have problems loading the model. I have already reinstalled Keras twice (also with --no-cache-dir).

Can you help me please?

$ python3 test.py

Output:

Using TensorFlow backend.
Using VGG-Face model backend and cosine distance.
Traceback (most recent call last):
  File "test.py", line 2, in <module>
    result = DeepFace.verify("/home/pi/img1.jpg", "/home/pi/img2.jpg")
  File "/home/pi/.local/lib/python3.7/site-packages/deepface/DeepFace.py", line 212, in verify
    input_shape_x = input_shape[0]

Edit:
On first run, the file vgg_face_weights.h5 was successfully downloaded

I did some debugging and inserted following line for the output:

print(model.layers[0].input_shape)

Output:
[(None, 224, 224, 3)]

@serengil
Copy link
Owner

Could you share your environment version?

import tensorflow
print(tensorflow.__version__)
import keras
print(keras.__version__)

@serengil
Copy link
Owner

BTW, if I print the input shape of 1st layer of the model, then it returns (None, 224, 224, 3) but you got [(None, 224, 224, 3)]. I think this is because we are using different versions.

Still, I'm going to add the following block in the next version of deepface. This will work in both returning types.

input_shape = custom_model.layers[0].input_shape

if type(input_shape) == list:
	input_shape = input_shape[0][1:3]
else:
	input_shape = input_shape[1:3]

I'm running unit tests now. It is going to be live in half hour. You should install the package "pip install deepface==0.0.31" after it published.

@serengil
Copy link
Owner

New version is on live. I think you can run deepface with this version even if you haven't change your tensorflow and keras versions.

https://pypi.org/project/deepface/0.0.31/

@maisen20
Copy link
Author

wow, thanks a lot for the very quick answer and help! i will test & watch it as soon as i have time.

@maisen20
Copy link
Author

maisen20 commented Jun 21, 2020

I tried deepface version 0.0.31, but I had problems with that too. The problem was with opencv, but seems to have nothing in common with my original problem in this issue.

The opencv version I was using (OpenCV 4.1.2 ) did not work correctly with raspbian (see EdjeElectronics/TensorFlow-Object-Detection-on-the-Raspberry-Pi#67 (comment) ).

So i installed opencv-python 3.4.6.27 (pip3 install opencv-python==3.4.6.27) and now it works.

Thank you serengil!

@serengil
Copy link
Owner

Please try the following version. That's exactly same version of mine. BTW, exception is same or changed? Could you share the new exception messages if it is changed.

pip install opencv-python==3.4.4

@maisen20
Copy link
Author

maisen20 commented Jun 21, 2020

Sorry, I had a typo in my answer. I meant "now it works".

So everything is working now with opencv-python 3.4.6.27.

@serengil
Copy link
Owner

It's awesome. Thank you for analysis as well. I could not solve this problem if you haven't analyze it.

@serengil serengil added the bug Something isn't working label Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants