Giter Site home page Giter Site logo

face_swap_docker's Introduction

xBerry setup

  1. Instal nvidia-docker
  2. Build docker Dockerfile
    docker build -t face_swap_gpu -f Dockerfile .
  3. Make sure that all needed models are in data directory
    cd data
    wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
    bzip2 -d shape_predictor_68_face_landmarks.dat.bz2
    wget https://github.com/YuvalNirkin/face_swap/releases/download/0.9/3dmm_cnn_resnet_101.zip
    unzip 3dmm_cnn_resnet_101.zip
    wget https://github.com/YuvalNirkin/face_segmentation/releases/download/1.0/face_seg_fcn8s.zip
    unzip face_seg_fcn8s.zip
    wget https://github.com/YuvalNirkin/face_segmentation/releases/download/1.1/face_seg_fcn8s_300_no_aug.zip
    unzip face_seg_fcn8s_300_no_aug.zip
    rm *.zip
  4. Modify config file in data/test.cfg. Especially input images data. All images has to be stored in data/images
  5. Run docker container with GPU support (At least 4GB of GPU memory needed)
    docker run --gpus 0 -it -v ${PWD}/data:/installations/face_swap/data face_swap bash
  6. Inside docker got to dir and run face_swap
    cd /installations/face_swap/bin
    ./face_swap_image --cfg ../data/test.cfg 
  7. Image is stored on local machine in directory data/images

PS: face_swap application guide

Acknowledgement

This work is done when the author is interning at AILabs.tw

Dockerized Fast Face Swap

This is a container for Fast Face Swap inherited from YuvalNirkin/face_swap with all dependency installed.

Since OpenGL is used, we leverage the browser interface from thewtex/docker-opengl to access OpenGL.

Prerequisite

You must have face_swap and yolo.so under this folder. You can clone them from Gitlab face_swap: git clone https://github.com/RudyChin/face_swap -b kcf (Default branch is kcf) yolo.so: git clone https://github.com/RudyChin/yolo.so.git

Models

./fetch_data.sh

Download dfm_cnn_resnet_101 and put them under models folder.

Existing Image

docker pull rudychin/face_swap_docker:gpu

Install

Install the docker image by ./build-gpu.sh (It will get nvidia-driver.run for you) You should prepare nvidia-driver.run with the same driver version installed on the host

There are several variables to be set in run-gpu.sh

Please set MODEL_PATH to path that contains the following models:

  1. landmarks, e.g. shape_predictor_68_face_landmarks.dat
  2. model_3dmm_h5, e.g. BaselFaceModel_mod_wForehead_noEars.h5
  3. model_3dmm_dat, e.g. BaselFace.dat
  4. reg_model, e.g. dfm_resnet_101.caffemodel
  5. reg_deploy, e.g. dfm_resnet_101_deploy.prototxt
  6. reg_mean, e.g. dfm_resnet_101_mean.binaryproto
  7. seg_model, e.g. face_seg_fcn8s.caffemodel
  8. seg_deploy, e.g. face_seg_fcn8s_deploy.prototxt

Please set IMAGE_PATH to contain the source images, e.g. Brad Pitt

Run

To run test on GPU 0:

./run-gpu.sh test 0

Noted that there are several idols to pick from: 0 (Brad Pitt), 1 (Emma Stone), 2 (Emma Watson), 3 (Donald Trump), 4 (Aniki), 5 (Nick Young) To change source idols, please modify codes in face_swap/py_face_swap/fs_service.py

Switch Algorithms (KCF / DLIB+YOLO)

Method 1

cd face_swap
git checkout {yolo/kcf}
cd ..
make docker-gpu #Suppose you have nvidia-driver.run already

Method 2

./run-gpu.sh 8899

docker# git checkout {yolo/kcf}
docker# cd build
docker# make -j12
docekr# make install

Notes for run-gpu.sh

The parameters given to the docker in run-gpu.sh is essential to enable OpenGL. You should especially take care of -e DISPLAY=:0. It should bind to the display. In case :0 doesn't work anymore:

  1. Physically login to the computer, e.g. ws2 (It should connect to a screen)
  2. Open a terminal
  3. check the working value of DISPLAY by echo $DISPLAY

face_swap_docker's People

Contributors

rudychin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.