[Script] Copy every Nth face to subfolder - Lightning fast facesets

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.

Post Reply
User avatar
Surrogator
Posts: 11
Joined: Sun Jul 14, 2019 11:39 pm
Has thanked: 2 times
Been thanked: 2 times

[Script] Copy every Nth face to subfolder - Lightning fast facesets

Post by Surrogator »

The following Windows batch script will create a subdirectory named subset in the working directory where it's called, and then copy every Nth file from the working directory into the subdirectory.

This is useful if you want to create a faceset from an extraction with a low Extract Every N setting (usually EEN=1 if you're using that video for conversion later). Instead of re-extracting those faces with FaceSwap at a higher EEN, you can use the following (Windows) script to copy 1 every N files into a subdirectory.

In the example below, the script lives here:

Code: Select all

C:\swaps\extractions\every.bat

When you call the script, you must provide a number for N. For example:

Code: Select all

.\every 10
every_bat.png
every_bat.png (123.08 KiB) Viewed 5495 times

Code: Select all

@ECHO off

SETLOCAL EnableDelayedExpansion
SET /A every = %1
SET /A index = 0
SET /A files = 0
SET /A count = 0

MKDIR subset

ECHO Making a copy every %every% files...

FOR %%G IN (*) DO (
    SET /A files += 1
    SET /A index += 1
    IF !index! EQU %every% (
        @COPY "%%G" .\subset 1>NUL
        SET /A count += 1
        SET /A index = 0
    )
)

ECHO Copied %count%/%files% files.

ENDLOCAL

Tags:

User avatar
Now
Posts: 10
Joined: Sat Jan 04, 2020 6:30 pm
Has thanked: 6 times
Been thanked: 1 time

Re: [Script] Copy every Nth face to subfolder - Lightning fast facesets

Post by Now »

thanks, will give it go next time, had problems doing this is the past.. want to keep the number of frames to a min... currently on 10 k either side.


Post Reply