viewing/modifying alignments.fsa?

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
korrupt78
Posts: 50
Joined: Wed Jan 29, 2020 1:34 am
Has thanked: 2 times
Been thanked: 1 time

viewing/modifying alignments.fsa?

Post by korrupt78 »

Is there a way to view the contents of an .fsa alignments file? This seems like the most basic admin/exploration tool, but I've spent 30m looking through docs and forums and search results and can't find it. I've even start looking at the code, but my Python is super-rusty, and my first attempt still wasn't working after about 15m:

Code: Select all

#!/usr/bin/env python
import os
import pickle
import zlib
with open( 'foo.fsa', 'rb' ) as foofile:
        data = foofile.read()
        data = zlib.decompress(data)
        data = pickle.loads(data)
        print( data )

Still produces noise.


Also, as there an easy way to change the basename used for extracted image filenames inside the alignments file? For example, imagine I originally had a file foo.mp4 that I ran an extraction on, producing a bunch of foo???????.png image files and a foo_alignments.fsa file that references the 'foo' basename.

Now imagine I wanted to change the basename of the video and resulting image set. How do I update the contents of the alignments file to conform to my desired new basename?

by bryanlyon » Wed Jan 29, 2020 1:55 am

We do not expose the fsa file since it's not final. That said, the intended way of manipulating the FSA is through the alignments tool (Including the manual tool).

You don't actually need to change the filename in the alignments.fsa since we use the hash of the image to find the matching alignment. In reality we're working away from facesets altogether but aren't there yet.

The only time the basename is used is if you use the "update_hash" job of the Alignment tool, which needs the filenames to match the original file in order to be able to relate the file to the alignments.

Go to full post
User avatar
bryanlyon
Site Admin
Posts: 793
Joined: Fri Jul 12, 2019 12:49 am
Answers: 44
Location: San Francisco
Has thanked: 4 times
Been thanked: 218 times
Contact:

Re: viewing/modifying alignments.fsa?

Post by bryanlyon »

We do not expose the fsa file since it's not final. That said, the intended way of manipulating the FSA is through the alignments tool (Including the manual tool).

You don't actually need to change the filename in the alignments.fsa since we use the hash of the image to find the matching alignment. In reality we're working away from facesets altogether but aren't there yet.

The only time the basename is used is if you use the "update_hash" job of the Alignment tool, which needs the filenames to match the original file in order to be able to relate the file to the alignments.

User avatar
korrupt78
Posts: 50
Joined: Wed Jan 29, 2020 1:34 am
Has thanked: 2 times
Been thanked: 1 time

Re: viewing/modifying alignments.fsa?

Post by korrupt78 »

That's all new and tremendously useful information to me - thanks!

I still wish there was a simple, straightforward way to view the contents of an .fsa file. It's such a basic operation, and managing black boxes that I can't examine or compare to each other makes me frustrated. I hope a "view" or "dump" or "info" job gets added to the alignments tool eventually.

User avatar
bryanlyon
Site Admin
Posts: 793
Joined: Fri Jul 12, 2019 12:49 am
Answers: 44
Location: San Francisco
Has thanked: 4 times
Been thanked: 218 times
Contact:

Re: viewing/modifying alignments.fsa?

Post by bryanlyon »

The data is viewable. You can use the manual tool to view the alignments. The only part of the alignments.fsa file that isn't yet in the manual tool is the mask, which will be added in the new version that is currently in the works.

User avatar
korrupt78
Posts: 50
Joined: Wed Jan 29, 2020 1:34 am
Has thanked: 2 times
Been thanked: 1 time

Re: viewing/modifying alignments.fsa?

Post by korrupt78 »

That's in the GUI, right? I haven't explored the GUI yet - only been using faceswap.py and tools.py directly on the command line. (I'm working on a desktop that's different than the linux box with my GPU, which is in another room. I'm SSHed in.)

I'll check it out soon, thanks.

User avatar
bryanlyon
Site Admin
Posts: 793
Joined: Fri Jul 12, 2019 12:49 am
Answers: 44
Location: San Francisco
Has thanked: 4 times
Been thanked: 218 times
Contact:

Re: viewing/modifying alignments.fsa?

Post by bryanlyon »

The GUI doesn't require a GPU and can run on any OS. So you can still use the manual tool locally. However, you can still see the alignments by using

Code: Select all

python tools.py alignments -j draw -a [alignments] -fr [frames_folder_or_video]

which will output the files with the alignments drawn on.

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

Re: viewing/modifying alignments.fsa?

Post by torzdf »

A small script that lets you iterate alignments file. Save in Faceswap folder and edit accordingly:

Code: Select all

_ALIGNMENTS_FOLDER = ""  # ENTER THE FOLDER THAT CONTAINS YOUR ALIGNMENTS
_ALIGNMENTS_FILENAME = "alignments.fsa"  # ENTER THE ALIGNMENTS FILE FILE NAME

from lib.logger import log_setup
log_setup("INFO", None, None, False)

from lib.alignments import Alignments

ALMNTS = Alignments(_ALIGNMENTS_FOLDER, _ALIGNMENTS_FILENAME).data

for frame, faces in ALMNTS.items():
    print("---------------------------\n{}\n---------------------------".format(frame))
    print(faces)
Last edited by torzdf on Mon Mar 02, 2020 5:16 pm, edited 1 time in total.
Reason: Update code for latest alignments update

My word is final

User avatar
korrupt78
Posts: 50
Joined: Wed Jan 29, 2020 1:34 am
Has thanked: 2 times
Been thanked: 1 time

Re: viewing/modifying alignments.fsa?

Post by korrupt78 »

Nice, that works - thanks!

Locked