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 when runing data_preparation.py #10

Closed
li-fang opened this issue Aug 5, 2021 · 2 comments
Closed

IndexError when runing data_preparation.py #10

li-fang opened this issue Aug 5, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@li-fang
Copy link

li-fang commented Aug 5, 2021

Hi! I tried to train the network on my own datasets. When I was preparing the landmarks by running the script "python data_preparation.py --img_folder <folder_to_training_images>", I got the following error message for one of the images:

Traceback (most recent call last):
File "data_preparation.py", line 48, in
data_prepare([os.path.join(opt.data_root, folder) for folder in opt.img_folder], opt.mode)
File "data_preparation.py", line 28, in data_prepare
detect_68p(img_folder, lm_sess, input_op, output_op) # detect landmarks for images
File "D:\Code\Python\Deep3DFaceRecon_pytorch\util\detect_lm68.py", line 105, in detect_68p
draw_landmarks(img, landmark, os.path.join(vis_path, name))
File "D:\Code\Python\Deep3DFaceRecon_pytorch\util\detect_lm68.py", line 29, in draw_landmarks
:] = np.array([0, 0, 255])
IndexError: index 432 is out of bounds for axis 0 with size 432

I changed corresponding index "img.shape[0]-landmark[i, 1]+j" to "img.shape[0]-1-landmark[i, 1]+j". And the above error didn't occur for the next try. I'm not sure if that's what you really meant.

BTW, thanks for sharing your work!

@YuDeng
Copy link
Collaborator

YuDeng commented Aug 6, 2021

Hi, thanks for pointing out this problem. "img.shape[0]-1-landmark[i, 1]+j" should be a better form to avoid out of bound issue if a detected landmark is quite close to image boundary. Alternatively you can clip the result within [0, image.shape-1].

This should have no influence to the training process because draw_landmarks function is only used for visualization purpose.

@li-fang
Copy link
Author

li-fang commented Aug 6, 2021

Thank you for your clarification!

@li-fang li-fang closed this as completed Aug 6, 2021
@YuDeng YuDeng added the bug Something isn't working label Aug 6, 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