Remove-Faces: update_png_headers IndexError: list index out of range

Want to know about the Faceswap's Face Extraction process? Got tips, ideas or just want to learn about how it all works? Then this is the place for you


Forum rules

Read the FAQs and search the forum before posting a new topic.

This forum is for discussing tips and understanding the process involved for Extracting and preparing face sets for training a model in Faceswap.

If you have found a bug are having issues with the Extraction process not working, then you should post in the Extract Support forum.

Please mark any answers that fixed your problems so others can find the solutions.

Locked
User avatar
gravitation
Posts: 15
Joined: Fri May 07, 2021 6:14 am
Has thanked: 10 times
Been thanked: 1 time

Remove-Faces: update_png_headers IndexError: list index out of range

Post by gravitation »

The following stack is shown after Tool->Alignment->Remove-Face runs.
It actually goes through fine, but right after it removes them, it throws this exception. And I check the file and it doesn't persist the changes to the alignment file.

Code: Select all

05/07/2021 12:42:52 INFO     13 alignment(s) were removed from alignments file
05/07/2021 12:42:54 ERROR    Got Exception on main handler:
Traceback (most recent call last):
  File "C:\Users\Jason\faceswap\lib\cli\launcher.py", line 182, in execute_script
    process.process()
  File "C:\Users\Jason\faceswap\tools\alignments\alignments.py", line 40, in process
    job.process()
  File "C:\Users\Jason\faceswap\tools\alignments\jobs.py", line 678, in process
    self._update_png_headers()
  File "C:\Users\Jason\faceswap\tools\alignments\jobs.py", line 712, in _update_png_headers
    face.from_alignment(self._alignments.get_faces_in_frame(frame)[new_index])
IndexError: list index out of range
05/07/2021 12:42:54 CRITICAL An unexpected crash has occurred. Crash report written to 'C:\Users\Jason\faceswap\crash_report.2021.05.07.124252443663.log'. You MUST provide this file if seeking assistance. Please verify you are running the latest version of faceswap before reporting

I read the guides, the comments on the guides, and surfed the other threads. Although some touched this subject, they failed to give me the answer to my issue. I also want to note that this exception is not thrown if I am using a single face-set. You understand in a bit.

I gathered all the files for this process. There were two folders containing a collection of images, and another folder containing vids. I performed the extract on both folders, and ALL the vids, and placed them all in a single folder. So that single folder contains multiple face-sets, estimated over 20+.

Then I Tools->Sort->Face that folder. When finished, I went through the entire contents and removed irrelevant content (that took a long time). Finally, I was ready to sync the alignment files against the removed faces. And here is where we hit the wall. I tried running it with the images alignment file, and some video alignment files, and the exception is the same for any of them.

I assumed this was something to do with the fact that I consolidated all the extracts into a single folder, so I thought that merging the alignments would solve my issue. I noticed that merging was no longer there and I read on why that was (I was happy about the change). But I did find that when you hover over the Alignments File field in the Tools->Alignments->Data section, the tooltip says that if I want to perform a merge to add the file paths to the alignments in a space delimited format. I tried to select the files via the file picker, but it only allowed one at a time. So I copied all the file paths and painstakingly formatted them to the tooltip's specification. However, to my dismay, the process treated that path as a single file in which it threw a file not found/invalid path exception. So I found out that merging no longer exists.

So, if there is something I can do to salvage this situation, I'm all ears. If there isn't, looks like I'll have to start over. Please help!

User avatar
torzdf
Posts: 2649
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 128 times
Been thanked: 622 times

Re: Remove-Faces: update_png_headers IndexError: list index out of range

Post by torzdf »

gravitation wrote: Fri May 07, 2021 8:26 pm

I assumed this was something to do with the fact that I consolidated all the extracts into a single folder,

This is exactly why this has happened.

But I did find that when you hover over the Alignments File field in the Tools->Alignments->Data section, the tooltip says that if I want to perform a merge to add the file paths to the alignments in a space delimited format.

This tooltip is no longer correct. Thanks for the heads up, I will fix this (multi-alignments can no longer be selected, because as you point out, merging alignments is no longer a thing).

So, if there is something I can do to salvage this situation, I'm all ears. If there isn't, looks like I'll have to start over. Please help!

At the moment, sadly not. The storage of alignment data in png headers for training is a relatively new addition to simplify the training process. Unfortunately the entire faceswap process is built around 1 source = 1 alignments file. At some point in the future at least some (or all) of what you want to do will be probably be possible, but it is a fairly significant change to the inner workings of the code, so it just has not been actioned yet, and may not be for a while.

For the time being it would be best to extract from a source, clean up that source's faces, update the alignments file and then move on to the next source. Dumping the training images into a single folder should be the last thing you do (I do understand the convenience and efficiency of extracting lots of sources and processing them altogether, but the supporting process is not there yet).

If you are proficient at all with scripting/coding, then you can actually rename the faces back to their original names as the original name is stored in the PNG header. If you can automate reading this information out of the header and rename the faces back, then you can pair the faces up to their original alignments file, and then clean up the files that way..

My word is final

User avatar
gravitation
Posts: 15
Joined: Fri May 07, 2021 6:14 am
Has thanked: 10 times
Been thanked: 1 time

Re: Remove-Faces: update_png_headers IndexError: list index out of range

Post by gravitation »

Thank you for your reply. While I was waiting for it, I decided to go ahead and start over and ended up doing it with the workflow you suggested in your reply. Now works great. I suppose practice can never hurt so I can get the training wheels off asap.

I think the following statements are definitely worthy of being in the Extraction Workflow Guide. Especially for us developers who like to optimize any workflow every chance we get. This would save us a lot of time in setting up protocols for repetitive tasks.

...the entire faceswap process is built around 1 source = 1 alignments file.

...it would be best to extract from a source, clean up that source's faces, update the alignments file and then move on to the next source. Dumping the training images into a single folder should be the last thing you do.

With that said, keep up the good work my man, this thing is awesome!

Locked