microsoft / Deep3DFaceReconstruction

Accurate 3D Face Reconstruction with Weakly-Supervised Learning: From Single Image to Image Set (CVPRW 2019)
MIT License
2.22k stars 446 forks source link

TypeError: 'list' object cannot be interpreted as an integer #4

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hi I tried running demo.py and getting this error Traceback (most recent call last): File "demo.py", line 76, in demo() File "demo.py", line 64, in demo shape = np.squeeze(face_shape,[0]) File "/usr/local/lib/python3.6/dist-packages/numpy/core/fromnumeric.py", line 1388, in squeeze return squeeze(axis=axis) TypeError: 'list' object cannot be interpreted as an integer

YuDeng commented 5 years ago

Hi I tried running demo.py and getting this error Traceback (most recent call last): File "demo.py", line 76, in demo() File "demo.py", line 64, in demo shape = np.squeeze(face_shape,[0]) File "/usr/local/lib/python3.6/dist-packages/numpy/core/fromnumeric.py", line 1388, in squeeze return squeeze(axis=axis) TypeError: 'list' object cannot be interpreted as an integer

Hi, I think it is due to the incompatibility of different numpy versions. Can you try to modify line 64 to: shape = np.squeeze(face_shape, axis = 0) and check if it works?

ghost commented 5 years ago

I get the same error even after changing line 64 to shape = np.squeeze(face_shape, axis = 0). Also I am trying to run this in google colab

YuDeng commented 5 years ago

There are several lines (64-66) using np.squeeze in demo.py. Do you get the same error if you change all these lines? If the error remains, could you try print(face_shape) to check its type and shape?

Actually, we use np.squeeze here only to reduce the first dimension of outputs (face_shape, face_color, landmarks). Because the raw outputs returned by Reconstruction function has a shape of [bachsize, ..., ... ].

If it cannot work with your environment, you can try to use np.reshape instead of np.squeeze to reduce the first dimension.

ghost commented 5 years ago

@YuDeng after changing these lines input_img = np.squeeze(input_img) shape = np.squeeze(face_shape, axis = 0) color = np.squeeze(face_color, axis = 0) landmarks_2d = np.squeeze(landmarks_2d, axis = 0)

no longer getting that error reconstructing... 1 /content/Deep3DFaceReconstruction/preprocessimg.py:19: FutureWarning: rcond parameter will change to the default of machine precision times max(M, N) where M and N are the input matrix dimensions. To use the future default and silence this warning we advise to pass rcond=None, to keep using the old, explicitly pass rcond=-1. k,,, = np.linalg.lstsq(A,b) 2 3 4 5 6 7 8 9 10 but output/ only has blank.txt

YuDeng commented 5 years ago

It is a bit weird. If the code runs without error, it should produce an obj file and a mat file for each input image. You can print the path in line 72-73 to see where these files are saved.

ghost commented 5 years ago

yes, it was saving them back to the input folder, also how can you test images outside the test data while getting the 5 landmark txt file?

YuDeng commented 5 years ago

To get 5 landmarks for test images, you can use dlib face detector(https://github.com/davisking/dlib) or any other libraries providing face detection api.