sensity-ai / dot

The Deepfake Offensive Toolkit
BSD 3-Clause "New" or "Revised" License
4.14k stars 411 forks source link

SimSwap & SimSwap HQ are not working #79

Closed OnlyStopOnTop closed 1 year ago

OnlyStopOnTop commented 1 year ago

:bug: Bug Report

SimSwap and SimswapHQ are not working. FOMM and faceswapping are.

As I try to run SimSwap I get the error code below:

(dot) C:\Users\alber\Desktop\dot-main>dot -c ./configs/simswap.yaml --target 0 --source "./data" --use_gpu
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\serialization.py:888: SourceChangeWarning: source code of class 'torch.nn.parallel.data_parallel.DataParallel' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\serialization.py:888: SourceChangeWarning: source code of class 'models.ArcMarginModel' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\serialization.py:888: SourceChangeWarning: source code of class 'models.ResNet' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\serialization.py:888: SourceChangeWarning: source code of class 'torch.nn.modules.conv.Conv2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\serialization.py:888: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.BatchNorm2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\serialization.py:888: SourceChangeWarning: source code of class 'torch.nn.modules.activation.PReLU' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\serialization.py:888: SourceChangeWarning: source code of class 'torch.nn.modules.pooling.MaxPool2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\serialization.py:888: SourceChangeWarning: source code of class 'torch.nn.modules.container.Sequential' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\serialization.py:888: SourceChangeWarning: source code of class 'models.SEBlock' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\serialization.py:888: SourceChangeWarning: source code of class 'torch.nn.modules.pooling.AdaptiveAvgPool2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\serialization.py:888: SourceChangeWarning: source code of class 'torch.nn.modules.linear.Linear' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\serialization.py:888: SourceChangeWarning: source code of class 'torch.nn.modules.activation.Sigmoid' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\serialization.py:888: SourceChangeWarning: source code of class 'torch.nn.modules.dropout.Dropout' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\serialization.py:888: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.BatchNorm1d' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
Traceback (most recent call last):
  File "C:\Users\alber\miniconda3\envs\dot\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\alber\miniconda3\envs\dot\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\alber\miniconda3\envs\dot\Scripts\dot.exe\__main__.py", line 7, in <module>
  File "C:\Users\alber\miniconda3\envs\dot\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\alber\miniconda3\envs\dot\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\alber\miniconda3\envs\dot\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\alber\miniconda3\envs\dot\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\alber\Desktop\dot-main\src\dot\__main__.py", line 206, in main
    run(
  File "C:\Users\alber\Desktop\dot-main\src\dot\__main__.py", line 67, in run
    _dot.generate(
  File "C:\Users\alber\Desktop\dot-main\src\dot\dot.py", line 131, in generate
    option.generate_from_camera(
  File "C:\Users\alber\Desktop\dot-main\src\dot\commons\model_option.py", line 184, in generate_from_camera
    self.create_model(opt_crop_size=opt_crop_size, **kwargs)
  File "C:\Users\alber\Desktop\dot-main\src\dot\simswap\option.py", line 100, in create_model
    self.model = create_model(
  File "C:\Users\alber\Desktop\dot-main\src\dot\simswap\models\models.py", line 31, in create_model
    model.initialize(
  File "C:\Users\alber\Desktop\dot-main\src\dot\simswap\fs_model.py", line 76, in initialize
    netArc_checkpoint = torch.load(arcface_model_path)
  File "C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\serialization.py", line 815, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\serialization.py", line 1043, in _legacy_load
    result = unpickler.load()
  File "C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\optim\sgd.py", line 30, in __setstate__
    super().__setstate__(state)
  File "C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\optim\optimizer.py", line 214, in __setstate__
    self.defaults.setdefault('differentiable', False)
AttributeError: 'SGD' object has no attribute 'defaults'
[ WARN:0@5.669] global D:\a\opencv-python\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (539) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback

Best regards

Ghassen-Chaabouni commented 1 year ago

@OnlyStopOnTop What torch version are you using? Is it 1.9.0? If not run this command after replacing the cuda_tag. pip install torch==1.9.0+<cuda_tag> torchvision==0.10.0+<cuda_tag> -f https://download.pytorch.org/whl/torch_stable.html

According to this issue https://github.com/neuralchen/SimSwap/issues/355 in the SimSwap repo it's an issue related with the torch version.

OnlyStopOnTop commented 1 year ago

I run torch 2.0 with CUDA 11.8 I checked the list for compatibility and that´s why I choosed torch 2.0

I´m not sure if torch 1.9 is for cuda 11.8

Ghassen-Chaabouni commented 1 year ago

I run torch 2.0 with CUDA 11.8 I checked the list for compatibility and that´s why I choosed torch 2.0

I´m not sure if torch 1.9 is for cuda 11.8

How about you try first installing torch 1.9.0 with cuda 11.1 and see if it will work pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html

If it doesn't, as a second step try downgrading cuda to version 11.1

OnlyStopOnTop commented 1 year ago

Unisntalled torch and cuda completly.

Installed CUDA 11.1 from nvidia

Than I wanted to install cuda toolkit with:

conda install cudatoolkit=11.1 and conda install cudatoolkit=111

I get:

(dot) C:\Users\alber\Desktop\dot-main>conda install cudatoolkit=11.1 Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Collecting package metadata (repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

Current channels:

To search for alternate channels that may provide the conda package you're looking for, navigate to

https://anaconda.org

and use the search bar at the top of the page.

Cuda 11.1 toolkit isn´t even available in the anaconda database. Could you please give me the right advice?

pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html

Does give me:

(dot) C:\Users\alber\Desktop\dot-main>python -c "import torch; print(torch.cuda.is_available())" C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\package_mock_zipreader.py:17: UserWarning: Failed to initialize NumPy: numpy.core.multiarray failed to import (Triggered internally at ..\torch\csrc\utils\tensor_numpy.cpp:67.) _dtype_to_storage = {data_type(0).dtype: data_type for data_type in _storages} Traceback (most recent call last): File "", line 1, in File "C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch__init.py", line 629, in from .functional import * # noqa: F403 File "C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\functional.py", line 6, in import torch.nn.functional as F File "C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\nn\init.py", line 1, in from .modules import * # noqa: F403 File "C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\nn\modules\init__.py", line 2, in from .linear import Identity, Linear, Bilinear, LazyLinear File "C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\nn\modules\linear.py", line 9, in from .lazy import LazyModuleMixin File "C:\Users\alber\miniconda3\envs\dot\lib\site-packages\torch\nn\modules\lazy.py", line 2, in from typing_extensions import Protocol ModuleNotFoundError: No module named 'typing_extensions'

giorgiop commented 1 year ago

@OnlyStopOnTop we now provide windows exes , can you give a try?

Ghassen-Chaabouni commented 1 year ago

This issue is outdated. Feel free to reopen it after pulling the latest updates