diff --git a/LINUX.md b/LINUX.md new file mode 100644 index 0000000..49d2fff --- /dev/null +++ b/LINUX.md @@ -0,0 +1,28 @@ +## **GNU/Linux installation instructions** +**!!! FFmpeg and NVIDIA Driver shall be already installed !!!** + +First of all, i strongly recommend to install Anaconda, that it was convenient to work with DeepFaceLab. + +Official instruction: https://docs.anaconda.com/anaconda/install/linux + +After, you can create environment with packages, needed by DeepFaceLab: +``` +conda create -y -n deepfacelab python==3.6.6 pathlib==1.0.1 scandir h5py==2.7.1 Keras==2.1.6 tensorflow-gpu==1.8.0 scikit-image tqdm +``` +Then activate environment: +``` +source activate deepfacelab +``` +And install the remained packages: +``` +conda install -y -c conda-forge opencv==3.4.1 +pip install dlib==19.10.0 git+https://www.github.com/keras-team/keras-contrib.git +``` +Now clone the repository and run... Good luck ;-) +``` +git clone https://github.com/iperov/DeepFaceLab +cd DeepFaceLab && chmod +x main.sh && ./main.sh +``` +**NOTE !!! Before launching DeepFaceLab, you should convince in that you already executed "source activate deepfacelab" !!!** + +P.S. English is not my native language, so please be kind to my mistakes. diff --git a/main.sh b/main.sh new file mode 100644 index 0000000..8440cc7 --- /dev/null +++ b/main.sh @@ -0,0 +1,75 @@ +#!/bin/bash +INTERNAL_DIR=`pwd` +WORKSPACE=$INTERNAL_DIR/workspace +PYTHON=`which python` + +PS3="Please enter your choice: " +options=("clear workspace" "extract PNG from video data_src" "data_src extract faces" "data_src sort" "extract PNG from video data_dst" "data_dst extract faces" "data_dst sort by hist" "train" "convert" "converted to mp4" "quit") +select opt in "${options[@]}" +do + case $opt in + "clear workspace" ) + echo -n "Clean up workspace? [Y/n] "; read workspace_ans + if [ "$workspace_ans" == "Y" ] || [ "$workspace_ans" == "y" ]; then + rm -rf $WORKSPACE + mkdir -p $WORKSPACE/data_src/aligned + mkdir -p $WORKSPACE/data_dst/aligned + mkdir -p $WORKSPACE/model + echo "Workspace has been successfully cleaned!" + fi + ;; + "extract PNG from video data_src" ) + echo -n "File name: "; read filename + echo -n "FPS: "; read fps + if [ -z "$fps" ]; then fps="25"; fi + ffmpeg -i $WORKSPACE/$filename -r $fps $WORKSPACE/data_src/%04d.png -loglevel error + ;; + "data_src extract faces" ) + echo -n "Detector? [dlib | mt | manual] "; read detector + echo -n "Multi-GPU? [Y/n] "; read gpu_ans + if [ "$gpu_ans" == "Y" ] || [ "$gpu_ans" == "y" ]; then gpu_ans="--multi-gpu"; else gpu_ans=""; fi + $PYTHON $INTERNAL_DIR/main.py extract --input-dir $WORKSPACE/data_src --output-dir $WORKSPACE/data_src/aligned --detector $detector $gpu_ans --debug + ;; + "data_src sort" ) + echo -n "Sort by? [blur | brightness | face-yaw | hue | hist | hist-blur | hist-dissim] "; read sort_method + $PYTHON $INTERNAL_DIR/main.py sort --input-dir $WORKSPACE/data_src/aligned --by $sort_method + ;; + "extract PNG from video data_dst" ) + echo -n "File name: "; read filename + echo -n "FPS: "; read fps + if [ -z "$fps" ]; then fps="25"; fi + ffmpeg -i $WORKSPACE/$filename -r $fps $WORKSPACE/data_dst/%04d.png -loglevel error + ;; + "data_dst extract faces" ) + echo -n "Detector? [dlib | mt | manual] "; read detector + echo -n "Multi-GPU? [Y/n] "; read gpu_ans + if [ "$gpu_ans" == "Y" ] || [ "$gpu_ans" == "y" ]; then gpu_ans="--multi-gpu"; else gpu_ans=""; fi + $PYTHON $INTERNAL_DIR/main.py extract --input-dir $WORKSPACE/data_dst --output-dir $WORKSPACE/data_dst/aligned --detector $detector $gpu_ans --debug + ;; + "data_dst sort by hist" ) + $PYTHON $INTERNAL_DIR/main.py sort --input-dir $WORKSPACE/data_dst/aligned --by hist + ;; + "train" ) + echo -n "Model? [ H64 (2GB+) | H128 (3GB+) | DF (5GB+) | LIAEF128 (5GB+) | LIAEF128YAW (5GB+) | MIAEF128 (5GB+) | AVATAR (4GB+) ] "; read model + echo -n "Multi-GPU? [Y/n] "; read gpu_ans + if [ "$gpu_ans" == "Y" ] || [ "$gpu_ans" == "y" ]; then gpu_ans="--multi-gpu"; else gpu_ans=""; fi + $PYTHON $INTERNAL_DIR/main.py train --training-data-src-dir $WORKSPACE/data_src/aligned --training-data-dst-dir $WORKSPACE/data_dst/aligned --model-dir $WORKSPACE/model --model $model $gpu_ans + ;; + "convert" ) + echo -n "Model? [ H64 (2GB+) | H128 (3GB+) | DF (5GB+) | LIAEF128 (5GB+) | LIAEF128YAW (5GB+) | MIAEF128 (5GB+) | AVATAR(4GB+) ] "; read model + $PYTHON $INTERNAL_DIR/main.py convert --input-dir $WORKSPACE/data_dst --output-dir $WORKSPACE/data_dst/merged --aligned-dir $WORKSPACE/data_dst/aligned --model-dir $WORKSPACE/model --model $model --ask-for-params + ;; + "converted to mp4" ) + echo -n "File name of destination video: "; read filename + echo -n "FPS: "; read fps + if [ -z "$fps" ]; then fps="25"; fi + ffmpeg -y -i $WORKSPACE/$filename -r $fps -i "$WORKSPACE/data_dst/merged/%04d.png" -map 0:a? -map 1:v -r $fps -c:v libx264 -b:v 8M -pix_fmt yuv420p -c:a aac -b:a 192k -ar 48000 "$WORKSPACE/result.mp4" -loglevel error + ;; + "quit" ) + break + ;; + *) + echo "Invalid choice!" + ;; + esac +done