faceswap安装说明

Installing Faceswap

Prerequisites

Machine learning essentially involves a ton of trial and error. You‘re letting a program try millions of different settings to land on an algorithm that sort of does what you want it to do. This process is really really slow unless you have the hardware required to speed this up.

The type of computations that the process does are well suited for graphics cards, rather than regular processors. It is pretty much required that you run the training process on a desktop or server capable GPU. Running this on your CPU means it can take weeks to train your model, compared to several hours on a GPU.

Hardware Requirements

TL;DR: you need at least one of the following:

  • A powerful CPU

    • Laptop CPUs can often run the software, but will not be fast enough to train at reasonable speeds
  • A powerful GPU
    • Currently only Nvidia GPUs are supported. AMD graphics cards are not supported. This is not something that we have control over. It is a requirement of the Tensorflow library.
    • The GPU needs to support at least CUDA Compute Capability 3.0 or higher. To see which version your GPU supports, consult this list: https://developer.nvidia.com/cuda-gpus Desktop cards later than the 7xx series are most likely supported.
  • A lot of patience

Supported operating systems

  • Windows 10 Windows 7 and 8 might work. Your milage may vary
  • Linux Most Ubuntu/Debian or CentOS based Linux distributions will work.
  • macOS GPU support on macOS is limited due to lack of drivers/libraries from Nvidia.

Alternatively there is a docker image that is based on Debian.

Important before you proceed

In its current iteration, the project relies heavily on the use of the command line, although a gui is available. if you are unfamiliar with command line tools, you may have difficulty setting up the environment and should perhaps not attempt any of the steps described in this guide. This guide assumes you have intermediate knowledge of the command line.

The developers are also not responsible for any damage you might cause to your own computer.

General Install Guide

Installing dependencies

  • Python >= 3.2

    • apt/yum install python3 (Linux)
    • Installer (Windows)
    • brew install python3 (macOS)
  • virtualenv and virtualenvwrapper may help when you are not using docker.
  • If you are using an Nvidia graphics card You should install CUDA (https://developer.nvidia.com/cuda-zone) and CUDNN (https://developer.nvidia.com/cudnn). If you do not plan to build Tensorflow yourself, make sure you install no higher than version 9.0 of CUDA and 7.0.x of CUDNN
  • dlib is required for face recognition and is compiled as part of the setup process. You will need the following applications for your os to successfully install dlib (nb: list may be incomplete. Please raise an issue if another prerequisite is required for your OS):
    • Windows: Visual Studio 2015, CMake v3.8.2
    • Linux: build-essential, cmake
    • macOS: xquartz

Getting the faceswap code

Simply download the code from http://github.com/deepfakes/faceswap - For development it is recommended to use git instead of downloading the code and extracting it.

For now, extract the code to a directory where you‘re comfortable working with it. Navigate to it with the command line. For our example we will use ~/faceswap/ as our project directory.

Setup

Enter the folder that faceswap has been downloaded to and run:

python setup.py

If setup fails for any reason you can still manually install the packages listed within requirements.txt

About some of the options

  • CUDA: For acceleration. Requires a good nVidia Graphics Card (which supports CUDA inside)
  • Docker: Provide a ready-made image. Hide trivial details. Get you straight to the project.
  • nVidia-Docker: Access to the nVidia GPU on host machine from inside container.

CUDA with Docker in 20 minutes.

INFO    The tool provides tips for installation
        and installs required python packages
INFO    Setup in Linux 4.14.39-1-MANJARO
INFO    Installed Python: 3.6.5 64bit
INFO    Installed PIP: 10.0.1
Enable  Docker? [Y/n]
INFO    Docker Enabled
Enable  CUDA? [Y/n]
INFO    CUDA Enabled
INFO    1. Install Docker
        https://www.docker.com/community-edition

        2. Install Nvidia-Docker & Restart Docker Service
        https://github.com/NVIDIA/nvidia-docker

        3. Build Docker Image For Faceswap
        docker build -t deepfakes-gpu -f Dockerfile.gpu .

        4. Mount faceswap volume and Run it
        # without gui. tools.py gui not working.
        nvidia-docker run --rm -it -p 8888:8888             --hostname faceswap-gpu --name faceswap-gpu             -v /opt/faceswap:/srv             deepfakes-gpu

        # with gui. tools.py gui working.
        ## enable local access to X11 server
        xhost +local:
        ## enable nvidia device if working under bumblebee
        echo ON > /proc/acpi/bbswitch
        ## create container
        nvidia-docker run -p 8888:8888             --hostname faceswap-gpu --name faceswap-gpu             -v /opt/faceswap:/srv             -v /tmp/.X11-unix:/tmp/.X11-unix             -e DISPLAY=unix$DISPLAY             -e AUDIO_GID=`getent group audio | cut -d: -f3`             -e VIDEO_GID=`getent group video | cut -d: -f3`             -e GID=`id -g`             -e UID=`id -u`             deepfakes-gpu

        5. Open a new terminal to interact with the project
        docker exec faceswap-gpu python /srv/tools.py gui

A successful setup log, without docker.

INFO    The tool provides tips for installation
        and installs required python packages
INFO    Setup in Linux 4.14.39-1-MANJARO
INFO    Installed Python: 3.6.5 64bit
INFO    Installed PIP: 10.0.1
Enable  Docker? [Y/n] n
INFO    Docker Disabled
Enable  CUDA? [Y/n]
INFO    CUDA Enabled
INFO    CUDA version: 9.1
INFO    cuDNN version: 7
WARNING Tensorflow has no official prebuild for CUDA 9.1 currently.
        To continue, You have to build your own tensorflow-gpu.
        Help: https://www.tensorflow.org/install/install_sources
Are System Dependencies met? [y/N] y
INFO    Installing Missing Python Packages...
INFO    Installing tensorflow-gpu
INFO    Installing pathlib==1.0.1
......
INFO    Installing tqdm
INFO    Installing matplotlib
INFO    All python3 dependencies are met.
        You are good to go.

Run the project

Once all these requirements are installed, you can attempt to run the faceswap tools. Use the -h or --help options for a list of options.

python faceswap.py -h

or run with gui to launch the GUI

python faceswap.py gui

Proceed to ../blob/master/USAGE.md

Notes

This guide is far from complete. Functionality may change over time, and new dependencies are added and removed as time goes on.

If you are experiencing issues, please raise them in the faceswap-playground repository instead of the main repo.

Windows Install Guide

Setting up Faceswap can seem a little intimidating to new users, but it isn‘t that complicated, although a little time consuming. It is recommended to use Linux where possible as Windows will hog about 20% of your GPU Memory, making Faceswap run a little slower, however using Windows is perfectly fine and 100% supported.

Prerequisites

Microsoft Visual Studio 2015

Important Make sure to downoad the 2015 version of Microsoft Visual Studio

Download and install Microsoft Visual Studio 2015 from: https://go.microsoft.com/fwlink/?LinkId=532606&clcid=0x409

On the install screen:

  • Select "Custom" then click "Next"
  • Uncheck all previously checked options
  • Expand "Programming Languages" and select "Visual C++"
  • Select "Next" and "Install"

Cuda

GPU Only If you do not have an Nvidia GPU you can skip this step.

At the time of writing Tensorflow (version 1.12) only supports Cuda up to version 9.0, but check https://www.tensorflow.org/install/gpu for the latest supported version. It is crucial that you download the correct version of Cuda.

Download and install the correct version of the Cuda Toolkit from: https://developer.nvidia.com/cuda-toolkit-archive

NB: Make a note of the install folder as you‘ll need to access it in the next step.

cuDNN

GPU Only If you do not have an Nvidia GPU you can skip this step.

As with Cuda you will need to install the correct version of cuDNN that the latest Tensorflow supports. At the time of writing this is Tensorflow v1.12 which supports cuDNN version 7.2, but check https://www.tensorflow.org/install/gpu for the latest supported version.

Download cuDNN from https://developer.nvidia.com/cudnn. You will need to create an account with Nvidia.

At the bottom of the list of latest cuDNN release will be a link to "Archived cuDNN Releases": 

Select this and choose the latest version of cuDNN that supports the version of Cuda you installed and has a minor version greater than or equal to the latest version that Tensorflow supports. (Eg Tensorflow 1.12 supports Cuda 9.0 and cuDNN 7.2. There is not an archived version of cuDNN 7.2 for Cuda 9.0, so select cuDNN version 7.3)

  • Open the zip file
  • Extract all of the files and folders into your Cuda folder (It is likely to be located in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA):

CMake

Install the latest stable release of CMake from https://cmake.org/download/. (Scroll down the page for Latest Releases and select the relevant Binary distribution installer for your OS).

When installing CMake make sure to enable the option to CMake to the system path: 

Anaconda

Download and install the latest Python 3 Anacconda from: https://www.anaconda.com/download/. Unless you know what you are doing, you can leave all the options at default.

Git

Download and install Git for Windows: https://git-scm.com/download/win. Unless you know what you are doing, you can leave all the options at default.

Setup

Reboot your PC, so that everything you have just installed gets registered.

Anaconda

Set up a virtual environment

  • Open up Anaconda Navigator
  • Select "Environments" on the left hand side
  • Select "Create" at the bottom
  • In the pop up:
    • Give it the name: faceswap
    • IMPORTANT: Select python version 3.5
    • Hit "Create" (NB: This may take a while as it will need to download Python 3.5) 

Entering your virtual environment

To enter the virtual environment:

  • Open up Anaconda Navigator
  • Select "Environments" on the left hand side
  • Hit the ">" arrow next to your faceswap environment and select "Open Terminal" 

Faceswap

  • If you are not already in your virtual environment follow these steps
  • Get the Faceswap repo by typing: git clone https://github.com/deepfakes/faceswap.git
  • Enter the faceswap folder: cd faceswap

Easy install

  • Enter python setup.py and follow the prompts.

If you have issues/errors follow the Manual install steps below.

Manual install

If dlib failed to install you can follow the steps to manually install dlib.
Once dlib is installed follow these steps:

  • Install tkinter (required for the GUI) by typing: conda install tk
  • Install requirements: pip install -r requirements.txt
  • Install Tensorflow (either GPU or CPU version depending on your setup):
    • GPU Version: pip install tensorflow-gpu
    • Non GPU Version: pip install tensorflow

Running Faceswap

  • If you are not already in your virtual environment follow these steps
  • Enter the faceswap folder: cd faceswap
  • Enter the following to see the list of commands: python faceswap.py -h or enter python faceswap.py gui to launch the GUI

Create a desktop shortcut

A desktop shortcut can be added to easily launch staight into the faceswap GUI:

  • Open Notepad
  • Paste the following:
%USERPROFILE%\Anaconda3\envs\faceswap\python.exe %USERPROFILE%/faceswap/faceswap.py gui
  • Save the file to your desktop as "faceswap.bat"

Updating faceswap

It‘s good to keep faceswap up to date as new features are added and bugs are fixed. To do so:

  • If you are not already in your virtual environment follow these steps
  • Enter the faceswap folder: cd faceswap
  • Enter the following git pull --all
  • Once the latest version has downloaded, make sure your requirements are up to date: pip install --upgrade -r requirements.txt

Dlib

You should only need to follow these steps if you want the latest Dlib code or the process was unable to install Dlib for you.

For reasons outside of our control, this is the trickiest part of the process, and most of the prerequisites you installed are to support just Dlib. It is recommended to build Dlib from source for 3 main reasons:

  1. To get the latest version
  2. Enable GPU Support in Dlib
  3. To prevent yourself running into a whole host of issues later in the process.

If you are not bothered about having GPU support or the latest version, scroll to the end of this section for a simple one-liner to install the CPU version of Dlib.

Build Latest Dlib with GPU Support

  • If you are not already in your virtual environment follow these steps
  • In the terminal type: git clone https://github.com/davisking/dlib.git
  • Enter the dlib folder: cd dlib
  • Add Visual Studio to your path by typing: SET PATH=%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin
  • Enter: python setup.py -G "Visual Studio 14 2015" install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA --clean

This will build and install dlib for you. It is worth backing up the generated .egg file somewhere so that you can re-install it if you ever need to rather than having to re-compile:

  • From within the dlib folder copy the file named dlib-xx.yy.zz-py3.5-win-amd64.egg to somewhere safe
  • If you ever need to install it again, then from within your virtual environment enter: python -m easy_install <path to saved .egg>

Once Dlib is built, you can remove Visual Studio and CMake from your PC.

Easy install of Dlib without GPU Support

NB: Don‘t do this if you have already compiled Dlib with GPU support.

  • If you are not already in your virtual environment follow these steps
  • In the terminal type: conda install -c conda-forge dlib

原文地址:https://www.cnblogs.com/2008nmj/p/10335885.html

时间: 2024-11-29 04:21:54

faceswap安装说明的相关文章

程序员体验AI换脸就不要用ZAO了,详解Github周冠军项目Faceswap的变脸攻略

本文链接:https://blog.csdn.net/BEYONDMA/article/details/100594136       上个月笔者曾在<银行家杂志>发文传统银行如何引领开放银行时代潮流,就曾指出AI换脸等技术的兴起将会我们未来的身份认证手段造成一定的麻烦.而最近ZAO换脸软件再次爆红社交媒体,而且其接近于霸王条款的使用协议也将对于用户隐私造成一定的风险,虽然后来ZAO公开致歉,不过这波热点效应也让Faceswap这个开源的AI换脸项目登顶Github周排行的榜首. AI换脸历程

OpenFaceswap 入门教程(1):软件安装篇

---恢复内容开始--- 众多换脸软件中,DeepFaceLab其实是安装和使用最方便,更新最快的,但是由于其没有可是化界面,对于很新手来说,可能入门还是有点难度.那么今天就来介绍一款操作极其直观和简单的换脸软件OpenFaceSwap.这款软件的安装和使用体验和Fakeapp类似,但是软件内核“先进”很多,因为Fakeapp已经停更很久了,而OpenFaceSwap的内核一直在更新. OpenFaceSwap是什么? Openfaceswap 基于开源软件Faceswap而定制的图形界面版本.

【AI换脸】Faceswap源代码换脸软件安装指南(转)

个人做个记录 [AI换脸]Faceswap源代码换脸软件安装指南 学习 2018-6-25 4939阅读53点赞13评论 下载安装VS2017(下载地址https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=15)(VS2015也可以,个人感觉新版安装快一些) 安装时选择VC++2015桌面工具和CMake工具.其他可按需选择. 等待安装完成. 不到10分钟安装完成.(vs

anaconda下安装的TensorFlow没有代码补全解决方案

本人的ide工具是pycharm,python环境是通过anaconda安装的python3.6 问题:TensorFlow和TensorFlow -gpu两个包均安装成功,但是在ide pycharm中,没有代码提示 解决方案,进入你的IED依赖工具包路径中,也就是你的ide工具python运行所在的环境下的安装包, 如anaconda默认的依赖工具包路径(root 路径为:C:\ProgramData\Anaconda3\Lib\site-packages\tensorflow) 本人使用的

安装Windows7系统时,提示:缺少所需的CD/DVD驱动器设备驱动程序

      测试机型:HP probook 430 g3       系统:Windows 7 Pro x64 现在笔记本电脑主板集成的USB口大多为3.0版本,而且一些厂商为了追求PC的轻薄,不再集成光驱,所以我们在安装系统时,一般只能通过U盘或U口外接光驱. 而当我们因为需要(安装OEM系统),在通过刻录软件(如UltraISO)将系统写入U盘或光盘的方式安装系统时,此时问题就可能悄悄出现了:因为Win7官方原版系统没有集成USB3.0驱动,所以可能的报错如下: 点击"浏览"或通过

Windows8.1-KB2999226-x64安装提示 此更新不适用你的计算机

如题 Windows8.1-KB2999226-x64.msu  双击安装 安装提示 此更新不适用你的计算机 . 解决方案: 放在D:\update\目录下 windows键+X  选择  命令提示符(管理员)  一定要是管理员 打开cmd 分别执行下面两句.红色部分就是自己的更新程序了.其他安装同理 例如Windows8.1-KB2919442-x64.msu 等 1    expand –F:* D:\update\Windows8.1-KB2999226-x64.msu D:\update

pip安装提示PermissionError: [WinError 5]错误问题解决

 问题现象 新安装python3.6版本后使用pip安装第三方模块失败,报错信息如下: C:\Users\linyfeng>pip install lxml Collecting lxml Downloading http://pypi.doubanio.com/packages/fb/41/b8d5c869d01fcb77c72d7d226a847a3946034ef19c244ac12920b71cd036/lxml-3.8.0-cp36-cp36m-win32.whl (2.9MB) 10

windows安装TortoiseGit详细使用教程【基础篇】

环境:win8.1 64bit 安装准备: 首先你得安装windows下的git msysgit1.9.5 安装版本控制器客户端tortoisegit  tortoisegit1.8.12.0 [32和64别下载错,不习惯英文的朋友,也可以下个语言包] 一.安装图解: 先安装GIT[一路默认即可] 安装好git以后,右键,会发现菜单多了几项关于GIT的选项 2.安装tortoisegit[一路默认即可] 安装好以后,右键,会发现菜单多了几项关于tortoisegit的选项 到此,安装算完成了,相

在Win10 Anaconda中安装Tensorflow

有需要的朋友可以参考一下 1.安装Anaconda 下载:https://www.continuum.io/downloads,我用的是Python 3.5 下载完以后,安装. 安装完以后,打开Anaconda Prompt,输入清华的仓库镜像,更新包更快: conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --set show_channel_url