Page 1 of 1

viewing/modifying alignments.fsa?

Posted: Wed Jan 29, 2020 1:42 am
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?


Re: viewing/modifying alignments.fsa?

Posted: Wed Jan 29, 2020 1:55 am
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.


Re: viewing/modifying alignments.fsa?

Posted: Wed Jan 29, 2020 2:19 am
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.


Re: viewing/modifying alignments.fsa?

Posted: Wed Jan 29, 2020 2:36 am
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.


Re: viewing/modifying alignments.fsa?

Posted: Wed Jan 29, 2020 2:51 am
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.


Re: viewing/modifying alignments.fsa?

Posted: Wed Jan 29, 2020 2:56 am
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.


Re: viewing/modifying alignments.fsa?

Posted: Wed Jan 29, 2020 11:27 am
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)

Re: viewing/modifying alignments.fsa?

Posted: Thu Jan 30, 2020 1:50 am
by korrupt78

Nice, that works - thanks!