Ubuntu Installation Guide - YuvalNirkin/fsgan GitHub Wiki

Installation guide for Ubuntu 18.04 (other versions were not tested but should work as well).

Dependencies

CUDA

CUDA Toolkit 10.1.

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget http://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-10-1-local-10.1.243-418.87.00/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda
rm *.deb

Anaconda

Anaconda distribution for Python 3.7.

wget https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh 
bash Anaconda3-2020.02-Linux-x86_64.sh 
rm Anaconda3-2020.02-Linux-x86_64.sh 

OpenCV

Quick installation using pip:

pip3 install opencv-python

Note: Some conda versions of OpenCV are missing the "avc1" codec that is used in this repository. The following is the preferred way to install OpenCV:

Developer Tools

sudo apt-get install build-essential cmake unzip pkg-config

Images and Videos

sudo apt-get install libjpeg-dev libpng-dev 
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev 
sudo apt-get install libxvidcore-dev libx264-dev

Optimization

sudo apt-get install libatlas-base-dev gfortran

Python3 dev tools

sudo apt-get install python3-dev

Numpy dependency

conda install numpy

Build from source see https://linuxize.com/post/how-to-install-opencv-on-ubuntu-20-04/

wget -O opencv.zip https://github.com/opencv/opencv/archive/4.3.0.zip
unzip opencv.zip
rm opencv.zip
cd opencv-4.3.0
mkdir build
cd build

cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=$(python -c "import sys; print(sys.prefix)") \
-D ENABLE_FAST_MATH=ON \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=OFF \
-D CMAKE_INSTALL_PREFIX=$(python -c "import sys; print(sys.prefix)") \
-D PYTHON_EXECUTABLE=$(which python) \
-D PYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON_PACKAGES_PATH=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-D BUILD_EXAMPLES=OFF \
-D BUILD_JPEG=ON ..

make -j8
sudo make install
sudo ldconfig

FFmpeg

sudo add-apt-repository ppa:jonathonf/ffmpeg-4
sudo apt-get update
sudo apt-get install ffmpeg

Python packages - see https://pytorch.org/get-started/locally/ for latest

conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c nvidia
conda install -c conda-forge yacs
pip install --upgrade tensorflow
pip install tensorboardX
pip install ffmpeg-python

For v1 only:

conda install -c 1adrianb face_alignment

FSGAN

Suggested directory structure

sudo mkdir -p /data
sudo chown <user>:<group> /data
mkdir -p /data/dev/projects
mkdir -p /data/datasets
mkdir -p /data/output

Clone repositories

cd /data/dev/projects
git clone https://github.com/YuvalNirkin/face_detection_dsfd
git clone https://github.com/YuvalNirkin/fsgan

Add to Python path

echo 'export PYTHONPATH=$PYTHONPATH:/data/dev/projects' >> ~/.profile
source ~/.profile
⚠️ **GitHub.com Fallback** ⚠️