偶然看到的:地址。
官网仓库介绍到:
拍个视频将其中的脸替换为您选择的面孔。您只需要一张所需面部的图像。不需要数据集,不需要训练。
使用确实也非常的简单,选一张头像照片,选一个视频,点击开始,等待视频生成完成。
感觉比之前介绍的SimSwap对新手友好很多啊(如果不考虑装环境的话)。
在Windows下安装需要一些别的,如果你没有请自行安装。
除了Python和Git,官方提示还需要:
将仓库克隆到本地目录。
roop> git clone https://github.com/s0md3v/roop
PowerShell 7.3.4
roop> pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
Writing to C:\Users\Shion\AppData\Roaming\pip\pip.ini
roop> virtualenv --version
virtualenv: The term 'virtualenv' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
roop> pip install virtualenv
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting virtualenv
Downloading https://mirrors.aliyun.com/pypi/packages/f1/0a/18755fa6aec794fd539b050beeaa905fa5c77c64356aa8bdecb62c01581a/virtualenv-20.23.0-py3-none-any.whl (3.3 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.3/3.3 MB 10.4 MB/s eta 0:00:00
Collecting filelock<4,>=3.11
Downloading https://mirrors.aliyun.com/pypi/packages/ad/73/b094a662ae05cdc4ec95bc54e434e307986a5de5960166b8161b7c1373ee/filelock-3.12.0-py3-none-any.whl (10 kB)
Collecting distlib<1,>=0.3.6
Downloading https://mirrors.aliyun.com/pypi/packages/76/cb/6bbd2b10170ed991cf64e8c8b85e01f2fb38f95d1bc77617569e0b0b26ac/distlib-0.3.6-py2.py3-none-any.whl (468 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 468.5/468.5 kB 9.8 MB/s eta 0:00:00
Collecting platformdirs<4,>=3.2
Downloading https://mirrors.aliyun.com/pypi/packages/89/7e/c6ff9ddcf93b9b36c90d88111c4db354afab7f9a58c7ac3257fa717f1268/platformdirs-3.5.1-py3-none-any.whl (15 kB)
Installing collected packages: distlib, platformdirs, filelock, virtualenv
Successfully installed distlib-0.3.6 filelock-3.12.0 platformdirs-3.5.1 virtualenv-20.23.0
在本地的Roop项目目录中执行。
roop> virtualenv venv
created virtual environment CPython3.10.11.final.0-64 in 1582ms
creator CPython3Windows(dest=D:\roop\venv, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\Shion\AppData\Local\pypa\virtualenv)
added seed packages: pip==23.1.2, setuptools==67.7.2, wheel==0.40.0
activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
roop> .\venv\Scripts\python.exe -mpip install -r requirements.txt
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting numpy==1.24.3 (from -r requirements.txt (line 1))
Downloading https://mirrors.aliyun.com/pypi/packages/65/5d/46da284b0bf6cfbf04082c3c5e84399664d69e41c11a33587ad49b0c64e5/numpy-1.24.3-cp310-cp310-win_amd64.whl (14.8 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.8/14.8 MB 11.1 MB/s eta 0:00:00
Collecting opencv-python==4.7.0.72 (from -r requirements.txt (line 2))
Downloading https://mirrors.aliyun.com/pypi/packages/36/98/fab8d982e2e2b57bdebcad64c7e5b5a14ac91c657cac509b9cf3fbea49d2/opencv_python-4.7.0.72-cp37-abi3-win_amd64.whl (38.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 38.2/38.2 MB 11.1 MB/s eta 0:00:00
Collecting onnx==1.14.0 (from -r requirements.txt (line 3))
Downloading https://mirrors.aliyun.com/pypi/packages/22/5c/46298252ea9f92b6b94184e8f001e575f2c346a22011498110fd032fc921/onnx-1.14.0-cp310-cp310-win_amd64.whl (13.3 MB)
......
太多了略
......
Collecting oauthlib>=3.0.0 (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.10,>=2.9->tensorflow>=2.0.0->opennsfw2==0.10.2->-r requirements.txt (line 10))
Downloading https://mirrors.aliyun.com/pypi/packages/7e/80/cab10959dc1faead58dc8384a781dfbf93cb4d33d50988f7a69f1b7c9bbe/oauthlib-3.2.2-py3-none-any.whl (151 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 151.7/151.7 kB 8.8 MB/s eta 0:00:00
Building wheels for collected packages: insightface, easydict
Building wheel for insightface (pyproject.toml) ... done
Created wheel for insightface: filename=insightface-0.7.3-cp310-cp310-win_amd64.whl size=841367 sha256=bbcfdf24a862127de6ec2a434f133ce3fa72e348c23f70da4b2f8125f6669c7b
Stored in directory: c:\users\shion\appdata\local\pip\cache\wheels\f3\96\01\d0647a259041eeb01dbfdfb3a43ad21ee3b18ca84b09869d8d
Building wheel for easydict (setup.py) ... done
Created wheel for easydict: filename=easydict-1.10-py3-none-any.whl size=6515 sha256=b6cba65f6f13e658494385be04c9e48f36ff89092a7ac467f0bd0c0c57cab05b
Stored in directory: c:\users\shion\appdata\local\pip\cache\wheels\6b\67\84\0f7f80aa3329df4012af7bf979008fca9133b91f6be61238b7
Successfully built insightface easydict
Installing collected packages: wcwidth, tk, tensorboard-plugin-wit, pyreadline3, mpmath, libclang, keras, flatbuffers, easydict, wrapt, urllib3, typing-extensions, threadpoolctl, termcolor, tensorflow-io-gcs-filesystem, tensorflow-estimator, tensorboard-data-server, sympy, soupsieve, six, PyYAML, PySocks, pyparsing, pyasn1, psutil, protobuf, prettytable, pillow, packaging, oauthlib, numpy, networkx, MarkupSafe, markdown, lazy_loader, kiwisolver, joblib, idna, humanfriendly, grpcio, gast, fonttools, filelock, cython, cycler, colorama, charset-normalizer, certifi, cachetools, absl-py, werkzeug, tqdm, tifffile, scipy, rsa, requests, PyWavelets, python-dateutil, pyasn1-modules, opt-einsum, opencv-python-headless, opencv-python, onnx, keras-preprocessing, jinja2, imageio, h5py, google-pasta, contourpy, coloredlogs, beautifulsoup4, astunparse, torch, scikit-learn, scikit-image, requests-oauthlib, onnxruntime-gpu, matplotlib, google-auth, qudida, google-auth-oauthlib, gdown, tensorboard, albumentations, tensorflow, insightface, opennsfw2
Successfully installed MarkupSafe-2.1.2 PySocks-1.7.1 PyWavelets-1.4.1 PyYAML-6.0 absl-py-1.4.0 albumentations-1.3.0 astunparse-1.6.3 beautifulsoup4-4.12.2 cachetools-5.3.1 certifi-2023.5.7 charset-normalizer-3.1.0 colorama-0.4.6 coloredlogs-15.0.1 contourpy-1.0.7 cycler-0.11.0 cython-0.29.35 easydict-1.10 filelock-3.12.0 flatbuffers-1.12 fonttools-4.39.4 gast-0.4.0 gdown-4.7.1 google-auth-2.19.0 google-auth-oauthlib-0.4.6 google-pasta-0.2.0 grpcio-1.54.2 h5py-3.8.0 humanfriendly-10.0 idna-3.4 imageio-2.30.0 insightface-0.7.3 jinja2-3.1.2 joblib-1.2.0 keras-2.9.0 keras-preprocessing-1.1.2 kiwisolver-1.4.4 lazy_loader-0.2 libclang-16.0.0 markdown-3.4.3 matplotlib-3.7.1 mpmath-1.3.0 networkx-3.1 numpy-1.24.3 oauthlib-3.2.2 onnx-1.14.0 onnxruntime-gpu-1.15.0 opencv-python-4.7.0.72 opencv-python-headless-4.7.0.72 opennsfw2-0.10.2 opt-einsum-3.3.0 packaging-23.1 pillow-9.5.0 prettytable-3.7.0 protobuf-3.20.2 psutil-5.9.5 pyasn1-0.5.0 pyasn1-modules-0.3.0 pyparsing-3.0.9 pyreadline3-3.4.1 python-dateutil-2.8.2 qudida-0.0.4 requests-2.31.0 requests-oauthlib-1.3.1 rsa-4.9 scikit-image-0.20.0 scikit-learn-1.2.2 scipy-1.10.1 six-1.16.0 soupsieve-2.4.1 sympy-1.12 tensorboard-2.9.0 tensorboard-data-server-0.6.1 tensorboard-plugin-wit-1.8.1 tensorflow-2.9.0 tensorflow-estimator-2.9.0 tensorflow-io-gcs-filesystem-0.31.0 termcolor-2.3.0 threadpoolctl-3.1.0 tifffile-2023.4.12 tk-0.1.0 torch-2.0.1 tqdm-4.65.0 typing-extensions-4.6.2 urllib3-1.26.16 wcwidth-0.2.6 werkzeug-2.3.4 wrapt-1.15.0
先下载这个需要的insightface文件(谷歌网盘)(大约528MB左右)。
吐槽下,没有一个是我们直接能访问的。
有人问起,所以我上传到了抱脸网站的模型中。
把下载的文件放入roop项目的根目录。
如果文件名不是这个inswapper_128.onnx
请自己重命名一下。目录如下:
roop> .\venv\Scripts\python.exe .\run.py
主界面如下很简洁。
使用也很简单,只需:
第一次运行的时候,还会自动下载一些文件(都不算太大)。
如果太慢就根据PowerShell里面显示的下载url,自己通过迅雷或别的下载吧。
*.onnx
文件放入C:\Users\你的用户名\.insightface\models\buffalo_l\
目录中。C:\Users\你的用户名\.opennsfw2\weights\
目录中。当然,如果自动下载比较快,就别手动折腾了。
因为CPU处理真的慢,所以还是需要显卡加速的。
我只有N卡,所以AMD那边请参考官网吧。
NV的官方页面地址。
下载完了安装一下(官方说要装,我不知道到为啥要装,然后又卸载了)。
1)下载
NV的官方页面地址,这个archive地址才能看到链接,而download地址要先登录。
我用的是cuDNN v8.9.1 (May 5th, 2023), for CUDA 11.x,这个压缩包。
要注册登录其实没啥,但是慢到无法操作。既然已经看到链接,我就用迅雷下载了。。。
2)放置并加路径
我解压放入C:\Program Files\NVIDIA GPU Computing Toolkit\cudnn-8.6.0.163_cuda11
目录的。
并且把C:\Program Files\NVIDIA GPU Computing Toolkit\cudnn-8.6.0.163_cuda11\bin
目录加入系统Path里。
PS:并不是非要这个目录名。
roop> .\venv\Scripts\python.exe -m pip uninstall onnxruntime onnxruntime-gpu
roop> .\venv\Scripts\python.exe -m pip install torch==2.0.0+cu118 torchvision==0.15.1+cu118 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu118
roop> .\venv\Scripts\python.exe -m pip install onnxruntime-gpu
如果前面步骤没问题,那么运行时加入--gpu
参数。
roop> .\venv\Scripts\python.exe .\run.py --gpu
使用GPU后生成快很多(大概快了几十倍吧),其它基本是一样的。
我这边如果弄好了GPU,那么再用CPU运行会卡住不动,也没报错,暂时不懂。
PS:很可能是缺少onnxruntime
的问题。