how to get the preview?

Want to use Faceswap in The Cloud? This is not directly supported by the Devs, but you may find community support here


Forum rules

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

NB: The Devs do not directly support using Cloud based services, but you can find community support here.

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

Locked
User avatar
curtain
Posts: 4
Joined: Fri May 08, 2020 6:35 pm
Has thanked: 1 time

how to get the preview?

Post by curtain »

I train the model in google colab.It will give mistakes when I use -p prametes in command line.How should I do?


User avatar
torzdf
Posts: 1439
Joined: Fri Jul 12, 2019 12:53 am
Answers: 125
Has thanked: 48 times
Been thanked: 278 times

Re: how to get the preview?

Post by torzdf »

The preview file will be saved to the root of your faceswap folder

My word is final


User avatar
Tekniklee
Posts: 37
Joined: Fri Jan 31, 2020 6:03 pm
Has thanked: 7 times
Been thanked: 3 times

Re: how to get the preview?

Post by Tekniklee »

Although the timelapse images may look cool, they are limited to the 14 images selected. The previews, on the other hand, eventually contain all of the images, so are more valuable than the timelapse in judging actual progress.

To collect these previews I made a batch file (at bottom) that looks for the training_preview.jpg file in the install directory, and then moves it to your collection directory using a unique time-based file name. There are no parameters, and the ONLY thing that needs to be modified in this batch file is the FaceSwap install location. This is where the hard coded "training_preview.jpg" file will be written by FaceSwap. So change that to point to your install root, such as "F:\FaceSwap NVIDIA GPU" in my case.

In my work environment, I separate training projects into their own directories, such as F:\Faceswap Working\Project1, and under each of those project directories I have directories for Model, Timelapse-Out (for preview images), Timelapse (for timelapse images). Some use the Timelapse-Out folder for their timelapse movie. I could never get that to work right, so I ended up using that directory to save my previews. I eventually did get the timelapse working with the first 14 images in each training set, so I used Timelapse for those. That's evolution for you - messy, but it eventually gets the job done. Fortunately, where you choose to save them is irrelavant. I keep individual faces, frames and alignments organized under a separate folder (F:\Faceswap aligned), and just point to them when it's time to train a project.

Place the batch file in the directory common to all training projects, such as "F:\Faceswap Working" in my case. This lets me easily use the same batch file for any project, with no parameters needed. To use the batch file, open a DOS prompt and change into the directory where you want to collect the images, such as "F:", then "CD \Faceswap Working\Project1\Timelapse-Out" in my case. Execute the batch file (located two directories above) by typing "..\..\savepreview.bat". The batch file will confirm the directory I am sitting in, and then begin monitoring the install directory. When a preview file is found, it slaps a unique name on it and moves it into the current directory (Timelapse-Out).

If you're using a blistering fast GPU (at least compared to mine) you may need to adjust the timing to look more frequently than every 60 seconds. Or you can increase the save value on the Training tab to something >100 that will give you >1 minute between saves. I doubt anyone would need to add time resolution faster than seconds, at least not for a couple more years. If you do I'm jealous to the point where you can figure how to add the milliseconds to the file name on your own!

Here is the batch file:

Code: Select all

@echo off
: SavePreview.bat
echo FaceSwap training preview save
echo Monitors FaceSwap program directory root and looks for file training_preview.jpg
echo If found, moves it to unique filename "training-YYYYMMDD-hhmmss.jpg" in CURRENT dir
echo This program is run from INSIDE the directory that is to receive the images.
echo .
: -------------------------------------------------------------------------
: >>> CHANGE THE PATH BELOW TO POINT TO YOUR FACESWAP INSTALL DIRECTORY <<<
: >>> DO NOT CHANGE FILENAME - IT IS FIXED                              <<<
: -------------------------------------------------------------------------
set "fsinstallpath=F:\FaceSwap NVIDIA GPU\"
set "filepath=%fsinstallpath%training_preview.jpg"
echo FaceSwap install path is: %fsinstallpath%
echo Watching for: %filepath%
echo .
:
: Provide current location warning
echo CURRENT DIRECTORY IS: %CD%
echo .
echo =====================================================================
echo ==  IF THIS IS NOT THE RECEIVING DIRECTORY ABORT NOW USING CTRL-C ===
echo =====================================================================
echo .
:top
: Check to see if a training preview file is present, and if so move it
if exist "%filepath%" GOTO movefile
: If not, show current time and wait
time /t
timeout 60 >nul
GOTO top
:movefile
: Create current timestamp string
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "fullstamp=%YYYY%%MM%%DD%_%HH%%Min%%Sec%"
echo File found. Time: %fullstamp%
move "%filepath%" ".\training-%fullstamp%.jpg" >nul
GOTO top
:end

Locked