Faceswap 3 open for testing

Discussions about research, Faceswapping and things that don't fit in the other categories here.


Post Reply
User avatar
torzdf
Posts: 2742
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 141 times
Been thanked: 639 times

Faceswap 3 open for testing

Post by torzdf »

Faceswap 3 is in Beta

Over the past few months I have been busy updating Faceswap to use Keras 3/PyTorch as its backend.

This is a major change, the reasons being that Tensorflow have made some baffling decisions of late that make it harder and harder to support going forward.

This has been a mammouth task, but ultimately, Faceswap will eventually switch over to this version at some point in the future, when all bugs are fixed and all features implemented.

Not yet implemented

In the meantime everything should work (including backwards compatibility) with the exception of:

  • Distributed training (this is on the roadmap to add prior to fully switching Faceswap over to PyTorch)
  • DirectML support. This may never be implemented, unless Keras 3 starts to support it. Ultimately, it is not possible to support this backend at present, so Windows users on AMD/Intel should stick with Faceswap 2

Implemented but untested

The following are implemented, but are untested until I receive feedback from users:

  • ROCm (AMD) support on Linux
  • Apple Silicon support

Testing required

I am now looking for testers to use the latest version so that I can fix bugs prior to mainlining this version of Faceswap. Be aware... there will be bugs, and I really need your help to report them, so that I can get this into a workable state.

New features

In addition to switching the backend to PyTorch, the following features have been added (amongs others):

  • More Optimizers (including LioN)
  • More configuration options for Optimizers (such as EMA, weight decay and Gradient Accumulation)
  • Vertical offset when training. This allows you to adjust the Y-offset of the face when training/converting. For example, if the target has a longer beard, you can adjust the y-offset to include more beard at the expense of forehead
  • New encoder for Phaze-A (ConvNeXt)

Installation

During testing there will be no installer for FS3, so please follow these instructions to install the FS3 beta:

Start > Anaconda prompt (for Windows. For Linux/macOS users, just open a standard Terminal)

Code: Select all

git clone https://github.com/deepfakes/faceswap.git fs3
cd fs3
git checkout fs3

conda create -n fs3 python=3.11
conda activate fs3

For Nvidia:

Code: Select all

python setup.py --installer --nvidia

For Apple Silicon:

Code: Select all

python setup.py --installer --apple-silicon

For ROCm:

Code: Select all

python setup.py --installer --rocm

Launch

Close the Terminal/Anaconda Prompt and re-open

Code: Select all

conda activate fs3
cd fs3
python faceswap.py gui

My word is final

User avatar
Barnuble
Posts: 21
Joined: Tue Jan 19, 2021 2:42 pm
Been thanked: 3 times

Re: Faceswap 3 open for testing

Post by Barnuble »

Hi everybody,

I tried to install FS3

I get this error :
WARNING Couldn't install ['"pytorch>=2.2.2,<2.4.0"', 'pytorch-cuda==12.1', '"torchaudio>=2.2.2,<2.4.0"', '"torchvision<0.19.0,>=0.17.2"'] with Conda. Please install this package manually

I tried to install it manually with the following command:
conda install pytorch torchvision torchaudio -c pytorch

...but I keep getting errors on launch... Will you create an installer ?

Thanks in advance !

User avatar
torzdf
Posts: 2742
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 141 times
Been thanked: 639 times

Re: Faceswap 3 open for testing

Post by torzdf »

Hi.

Thanks for trying to install. These are exactly the kind of errors that I am trying to iron out before mainlining the code....

You are the first person I have heard of that has hit this issue. As PyTorch is the first thing that is installed, this really shouldn't happen. Please could you provide me with the log file faceswap_setup.log from within your fs3 folder so that I can see what may have gone wrong (the file is likely to be large, so you may need to put it on pastebin).

Barnuble wrote: Sun Jun 23, 2024 2:36 pm

Will you create an installer ?

Yes, but the installer just automates the commands that you are running manually, so you are likely to hit the same issues with the installer too, unless I can remedy the issue. Either way, the installer will only come when the code is mainlined.

My word is final

User avatar
Barnuble
Posts: 21
Joined: Tue Jan 19, 2021 2:42 pm
Been thanked: 3 times

Re: Faceswap 3 open for testing

Post by Barnuble »

Hi,

Here's what i get when starting FS3 :
(I removed user name)

Setting Faceswap backend to NVIDIA
ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.
Traceback (most recent call last):
File "C:\Users\**\faceswap\fs3\faceswap.py", line 60, in <module>
_main()
File "C:\Users\*
\faceswap\fs3\faceswap.py", line 45, in main
generate_configs()
File "C:\Users\*
\faceswap\fs3\lib\config.py", line 650, in generate_configs
mod = import_module(f"plugins.{section}.
config")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\*
\MiniConda3\envs\fs3\Lib\importlib\__init.py", line 126, in import_module
return bootstrap.gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1204, in gcd_import
File "<frozen importlib.
bootstrap>", line 1176, in find_and_load
File "<frozen importlib.
bootstrap>", line 1126, in find_and_load_unlocked
File "<frozen importlib.
bootstrap>", line 241, in call_with_frames_removed
File "<frozen importlib.
bootstrap>", line 1204, in gcd_import
File "<frozen importlib.
bootstrap>", line 1176, in find_and_load
File "<frozen importlib.
bootstrap>", line 1147, in find_and_load_unlocked
File "<frozen importlib.
bootstrap>", line 690, in load_unlocked
File "<frozen importlib.
bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Users\*
\faceswap\fs3\plugins\extract\__init.py", line 3, in <module>
from .extract_media import ExtractMedia
File "C:\Users\*
\faceswap\fs3\plugins\extract\extract_media.py", line 7, in <module>
import cv2
File "C:\Users\*
\MiniConda3\envs\fs3\Lib\site-packages\cv2\__init.py", line 181, in <module>
bootstrap()
File "C:\Users\*
\MiniConda3\envs\fs3\Lib\site-packages\cv2\__init.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\*
***\MiniConda3\envs\fs3\Lib\importlib\__init__.py", line 126, in import_module
return bootstrap.gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: numpy._core.multiarray failed to import

Hope it can help...

User avatar
torzdf
Posts: 2742
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 141 times
Been thanked: 639 times

Re: Faceswap 3 open for testing

Post by torzdf »

Ok.I'm a bit confused here as you said you couldn't install it.

Either way, unfortunately this message doesn't tell me enough information. I would need the crash report in the faceswap folder as well as (assuming you are having installation issues) the faceswap_setup log.

You are welcome to PM them to me for privacy reasons.

My word is final

User avatar
landlocked
Posts: 7
Joined: Tue Jun 25, 2024 10:47 pm
Been thanked: 1 time

Re: Faceswap 3 open for testing

Post by landlocked »

I thought I would upgrade to FS3 to test it out, and I have hit a snag or two.

A number of packages seem to not fully install, but, oddly, if I try to manually install them after the incomplete FS3 install, the package always ends with the "you're good to go" message.

Attached in a Zip: Install screen log, bash error when trying to execute, and the FS3 crash report.

Thanks!

Landlocked

Attachments
FS3 Log and Bash Errors.zip
(12.7 KiB) Downloaded 287 times
User avatar
hash512
Posts: 3
Joined: Mon Mar 11, 2024 9:44 am

Re: Faceswap 3 open for testing

Post by hash512 »

Hi, I tried to install FS3 and apparently the installation process went fine.
Then, executing it gave me the following error:

Code: Select all

Microsoft Windows [Version 10.0.22631.3810]
(c) Microsoft Corporation. All rights reserved.

C:\Users\username>cd C:\Users\username\faceswapV3\

C:\Users\username\faceswapV3>C:\Users\username\Miniconda3\scripts\activate.bat"

(base) C:\Users\username\faceswapV3>conda activate fs3

(fs3) C:\Users\username\faceswapV3>cd fs3

(fs3) C:\Users\username\faceswapV3\fs3>python faceswap.py gui
Setting Faceswap backend to NVIDIA
07/04/2024 12:58:31 INFO     Log level set to: INFO
07/04/2024 12:58:35 ERROR    Got Exception on main handler:
Traceback (most recent call last):
  File "C:\Users\username\faceswapV3\fs3\lib\cli\launcher.py", line 185, in execute_script
    script = self._import_script()
             ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\username\faceswapV3\fs3\lib\cli\launcher.py", line 64, in _import_script
    module = import_module(mod)
             ^^^^^^^^^^^^^^^^^^
  File "C:\Users\username\MiniConda3\envs\fs3\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\username\faceswapV3\fs3\scripts\gui.py", line 9, in <module>
    from lib.gui import (TaskBar, CliOptions, CommandNotebook, ConsoleOut, DisplayNotebook,
  File "C:\Users\username\faceswapV3\fs3\lib\gui\__init__.py", line 4, in <module>
    from lib.gui.command import CommandNotebook
  File "C:\Users\username\faceswapV3\fs3\lib\gui\command.py", line 9, in <module>
    from .control_helper import ControlPanel
  File "C:\Users\username\faceswapV3\fs3\lib\gui\control_helper.py", line 15, in <module>
    from .custom_widgets import ContextMenu, MultiOption, ToggledFrame, Tooltip
  File "C:\Users\username\faceswapV3\fs3\lib\gui\custom_widgets.py", line 14, in <module>
    from .utils import get_config
  File "C:\Users\username\faceswapV3\fs3\lib\gui\utils\__init__.py", line 4, in <module>
    from .config import get_config, initialize_config, PATHCACHE
  File "C:\Users\username\faceswapV3\fs3\lib\gui\utils\config.py", line 12, in <module>
    from lib.gui._config import Config as UserConfig
  File "C:\Users\username\faceswapV3\fs3\lib\gui\_config.py", line 8, in <module>
    from matplotlib import font_manager
  File "C:\Users\username\MiniConda3\envs\fs3\Lib\site-packages\matplotlib\__init__.py", line 161, in <module>
    from . import _api, _version, cbook, _docstring, rcsetup
  File "C:\Users\username\MiniConda3\envs\fs3\Lib\site-packages\matplotlib\rcsetup.py", line 27, in <module>
    from matplotlib.colors import Colormap, is_color_like
  File "C:\Users\username\MiniConda3\envs\fs3\Lib\site-packages\matplotlib\colors.py", line 52, in <module>
    from PIL import Image
  File "C:\Users\username\MiniConda3\envs\fs3\Lib\site-packages\PIL\Image.py", line 88, in <module>
    from . import _imaging as core
ImportError: DLL load failed while importing _imaging: The specified module could not be found.
07/04/2024 12:58:35 CRITICAL An unexpected crash has occurred. Crash report written to 'C:\Users\username\faceswapV3\fs3\crash_report.2024.07.04.125832441395.log'. You MUST provide this file if seeking assistance. Please verify you are running the latest version of faceswap before reporting

(fs3) C:\Users\username\faceswapV3\fs3>

I'm attaching (https://we.tl/t-h0ZcmE8kjY - don't how to attach file on the forum :roll:) full logs and crash report. I'm available to further troubleshoot.

Thank you for keeping up this amazing project.

Regards,
hash512

Last edited by hash512 on Tue Jul 09, 2024 1:30 pm, edited 2 times in total.
User avatar
torzdf
Posts: 2742
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 141 times
Been thanked: 639 times

Re: Faceswap 3 open for testing

Post by torzdf »

Yes, this is a known issue under Windows...

I have pushed an installation update that I'm hoping will fix this.

Please run the following commands to clear the environment and then follow the installation instructions again. I would be keen to know if this update does remedy the issue.

Start > Anaconda prompt

Code: Select all

conda env remove -n fs3
conda clean --all -y
conda clean --all -y -f

My word is final

User avatar
torzdf
Posts: 2742
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 141 times
Been thanked: 639 times

Re: Faceswap 3 open for testing

Post by torzdf »

landlocked wrote: Tue Jul 02, 2024 4:41 am

I thought I would upgrade to FS3 to test it out, and I have hit a snag or two.

A number of packages seem to not fully install, but, oddly, if I try to manually install them after the incomplete FS3 install, the package always ends with the "you're good to go" message.

Attached in a Zip: Install screen log, bash error when trying to execute, and the FS3 crash report.

Thanks!

Landlocked

This is the same issue as above. Please follow the instructions in the previous post and let me know if it resolves your issue

My word is final

User avatar
hash512
Posts: 3
Joined: Mon Mar 11, 2024 9:44 am

Re: Faceswap 3 open for testing

Post by hash512 »

torzdf wrote: Tue Jul 09, 2024 5:56 pm

Yes, this is a known issue under Windows...

I have pushed an installation update that I'm hoping will fix this.

Please run the following commands to clear the environment and then follow the installation instructions again. I would be keen to know if this update does remedy the issue.

Start > Anaconda prompt

Code: Select all

conda env remove -n fs3
conda clean --all -y
conda clean --all -y -f

After all of this (cleanup + reinstall from git) I got the previous error again, exactly the same

User avatar
torzdf
Posts: 2742
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 141 times
Been thanked: 639 times

Re: Faceswap 3 open for testing

Post by torzdf »

I really wish Windows wasn't such a trash OS. I recommend using anything else.

This issue only impacts some Windows users and no one else. At this point I don't know what else I can do to fix it at install time as the bug does not happen to me.

In the meantime, can you please provide me with the file faceswap_setup.log from your faceswap folder. It is likely to be large, so you may need to zip it (you can PM me with it if you'd prefer). It may be useful to find out why exactly Windows is screwing up some people's install.

This should get you going, it has worked for others.

Start > Anaconda prompt

Code: Select all

conda activate fs3
pip uninstall pillow
pip install pillow
Last edited by torzdf on Tue Jul 09, 2024 11:57 pm, edited 2 times in total.

My word is final

User avatar
hash512
Posts: 3
Joined: Mon Mar 11, 2024 9:44 am

Re: Faceswap 3 open for testing

Post by hash512 »

torzdf wrote: Tue Jul 09, 2024 10:36 pm

I really wish Windows wasn't such a trash OS. I recommend using anything else.

This issue only impacts some Windows users and no one else. At this point I don't know what else I can do to fix it at install time as the bug does not happen to me.

In the meantime, can you please provide me with the file faceswap_setup.log from your faceswap folder. It is likely to be large, so you may need to zip it (you can PM me with it if you'd prefer). It may be useful to find out why exactly Windows is screwing up some people's install.

This should get you going, it has worked for others.

Start > Anaconda prompt

Code: Select all

conda activate fs3
pip uninstall pillow
pip install pillow

this fixed my fs3, thanks

User avatar
torzdf
Posts: 2742
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 141 times
Been thanked: 639 times

Re: Faceswap 3 open for testing

Post by torzdf »

Latest setup script should now handle the DLL issues for some Windows users

My word is final

User avatar
torzdf
Posts: 2742
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 141 times
Been thanked: 639 times

Re: Faceswap 3 open for testing

Post by torzdf »

@hash512 re: the following error:

Code: Select all

07/11/2024 21:16:23 MainProcess     _training                      io              _archive_model                 INFO     Archiving model folder 'C:\Users\username\Desktop\tmp\t\dp\model003_dfl-sae-df' to 'C:\Users\username\Desktop\tmp\t\dp\model003_dfl-sae-df_fs2_backup'
07/11/2024 21:16:23 MainProcess     _training                      multithreading  run                            DEBUG    Error in thread (_training): [WinError 5] Access is denied: 'C:\\Users\\username\\Desktop\\tmp\\t\\dp\\model003_dfl-sae-df' -> 'C:\\Users\\username\\Desktop\\tmp\\t\\dp\\model003_dfl-sae-df_fs2_backup'
07/11/2024 21:16:24 MainProcess     MainThread                     train           _monitor                       DEBUG    Thread error detected
07/11/2024 21:16:24 MainProcess     MainThread                     train           shutdown                       DEBUG    Sending shutdown to preview viewer
07/11/2024 21:16:24 MainProcess     MainThread                     train           _monitor                       DEBUG    Closed Monitor
07/11/2024 21:16:24 MainProcess     MainThread                     train           _end_thread                    DEBUG    Ending Training thread
07/11/2024 21:16:24 MainProcess     MainThread                     train           _end_thread                    CRITICAL Error caught! Exiting...
07/11/2024 21:16:24 MainProcess     MainThread                     multithreading  join                           DEBUG    Joining Threads: '_training'
07/11/2024 21:16:24 MainProcess     MainThread                     multithreading  join                           DEBUG    Joining Thread: '_training'
07/11/2024 21:16:24 MainProcess     MainThread                     multithreading  join                           ERROR    Caught exception in thread: '_training'
Traceback (most recent call last):
  File "C:\Users\username\faceswapV3_2\fs3\lib\cli\launcher.py", line 191, in execute_script
    process.process()
  File "C:\Users\username\faceswapV3_2\fs3\scripts\train.py", line 204, in process
    self._end_thread(thread, err)
  File "C:\Users\username\faceswapV3_2\fs3\scripts\train.py", line 244, in _end_thread
    thread.join()
  File "C:\Users\username\faceswapV3_2\fs3\lib\multithreading.py", line 224, in join
    raise thread.err[1].with_traceback(thread.err[2])
  File "C:\Users\username\faceswapV3_2\fs3\lib\multithreading.py", line 100, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\username\faceswapV3_2\fs3\scripts\train.py", line 268, in _training
    raise err
  File "C:\Users\username\faceswapV3_2\fs3\scripts\train.py", line 254, in _training
    model = self._load_model()
            ^^^^^^^^^^^^^^^^^^
  File "C:\Users\username\faceswapV3_2\fs3\scripts\train.py", line 280, in _load_model
    model: ModelBase = PluginLoader.get_model(self._args.trainer)(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\username\faceswapV3_2\fs3\plugins\train\model\dlight.py", line 28, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Users\username\faceswapV3_2\fs3\plugins\train\model\_base\model.py", line 90, in __init__
    self._io = IO(self, model_dir, self._is_predict, self.config["save_optimizer"])
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\username\faceswapV3_2\fs3\plugins\train\model\_base\io.py", line 98, in __init__
    self._update_legacy()
  File "C:\Users\username\faceswapV3_2\fs3\plugins\train\model\_base\io.py", line 153, in _update_legacy
    Legacy(old_fname)
  File "C:\Users\username\faceswapV3_2\fs3\plugins\train\model\_base\io.py", line 569, in __init__
    self._upgrade_model()
  File "C:\Users\username\faceswapV3_2\fs3\plugins\train\model\_base\io.py", line 854, in _upgrade_model
    archive_dir = self._archive_model()
                  ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\username\faceswapV3_2\fs3\plugins\train\model\_base\io.py", line 810, in _archive_model
    os.rename(model_dir, dst_path)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\username\\Desktop\\tmp\\t\\dp\\model003_dfl-sae-df' -> 'C:\\Users\\username\\Desktop\\tmp\\t\\dp\\model003_dfl-sae-df_fs2_backup'

I've moved this back to the main thread as I would prefer issues people may hit to have wider visibility.

I have just tested this on a Windows box and it works fine...

Code: Select all

07/12/2024 15:11:17 INFO     Upgrading model file from Faceswap 2 to Faceswap 3...
07/12/2024 15:11:19 INFO     Archiving model folder 'd:\fstest\train\fs2' to 'd:\fstest\train\fs2_fs2_backup'
07/12/2024 15:11:20 INFO     Model upgraded: 'd:\fstest\train\fs2'
07/12/2024 15:11:20 INFO     No existing state file found. Generating.
07/12/2024 15:11:26 INFO     Loaded model from disk: 'd:\fstest\train\fs2\original.keras'

I thought that the issue may have been trying to upgrade a model to fs3 when an fs2 backup already, but I have already covered this scenario off:

Code: Select all

07/12/2024 15:12:15 INFO     Upgrading model file from Faceswap 2 to Faceswap 3...
07/12/2024 15:12:17 CRITICAL Error caught! Exiting...
07/12/2024 15:12:17 ERROR    Caught exception in thread: '_training'
07/12/2024 15:12:17 ERROR    The destination archive folder 'd:\fstest\train\fs2_fs2_backup' already exists. Either delete this folder, select a different model folder, or remove the legacy model files from your model folder 'd:\fstest\train\fs2'.

So, ultimately, this issue is a permission error. Faceswap is asking Windows to copy the old folder to a new location. Windows is saying 'No'.

The best I can suggest, at this time, is to try moving your model folder to a different location. It may also be something like a virus checker locking the folder, preventing regular permissions.

Last edited by torzdf on Fri Jul 12, 2024 2:24 pm, edited 1 time in total.

My word is final

User avatar
mkjai
Posts: 1
Joined: Mon Jul 01, 2024 4:25 pm

Re: Faceswap 3 open for testing

Post by mkjai »

Fyi for AMD users. 7900xtx tested with Rocm 6.1. It works. ;)

User avatar
torzdf
Posts: 2742
Joined: Fri Jul 12, 2019 12:53 am
Answers: 159
Has thanked: 141 times
Been thanked: 639 times

Re: Faceswap 3 open for testing

Post by torzdf »

Thank you for confirming :)

My word is final

Post Reply