diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8bd325b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM continuumio/miniconda3 +USER root +RUN apt-get update +RUN apt-get install ffmpeg libsm6 libxext6 -y +# Create the environment: +COPY environment.yml . +RUN conda env create -f environment.yml +# Make RUN commands use the new environment: +RUN echo "conda activate adaface" >> ~/.bashrc +SHELL ["/bin/bash", "--login", "-c"] +COPY requirements.txt . +RUN pip install -r requirements.txt +WORKDIR /adaface +ENTRYPOINT ["./entrypoint.sh"] + diff --git a/README.md b/README.md index 25e6eff..cb1a328 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,23 @@ conda activate adaface conda install scikit-image matplotlib pandas scikit-learn pip install -r requirements.txt ``` +
+ +Docker Installation + +Note: Install NVIDIA Container Toolkit + +- Install +```js +sudo docker build -t adaface . +``` +- Run +```js +sudo docker run --gpus all -v ${PWD}:/adaface adaface +``` + +
+ # Train (Preapring Dataset and Training Scripts) - Please refer to [README_TRAIN.md](./README_TRAIN.md) @@ -109,7 +126,7 @@ This is different from the InsightFace released model which uses RGB color chann | R100 | WebFace12M | [gdrive](https://drive.google.com/file/d/1dswnavflETcnAuplZj1IOKKP0eM8ITgT/view?usp=sharing) | -# Inferece +# Inference ### Example using provided sample images AdaFace takes input images that are preproccsed. diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..9e8a7fe --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,19 @@ +#!/bin/bash --login +# The --login ensures the bash configuration is loaded, +# enabling Conda. + +# Enable strict mode. +set -euo pipefail +# ... Run whatever commands ... + +# Temporarily disable strict mode and activate conda: +set +euo pipefail +conda activate adaface + +# Re-enable strict mode: +set -euo pipefail + +# exec the final command: + +exec python start.py + diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..6e33d39 --- /dev/null +++ b/environment.yml @@ -0,0 +1,64 @@ +name: adaface +channels: + - pytorch + - defaults +dependencies: + - _libgcc_mutex=0.1=main + - _openmp_mutex=5.1=1_gnu + - blas=1.0=mkl + - bzip2=1.0.8=h7b6447c_0 + - ca-certificates=2023.01.10=h06a4308_0 + - certifi=2022.12.7=py38h06a4308_0 + - cudatoolkit=10.2.89=hfd86e86_1 + - ffmpeg=4.3=hf484d3e_0 + - flit-core=3.6.0=pyhd3eb1b0_0 + - freetype=2.12.1=h4a9f257_0 + - giflib=5.2.1=h5eee18b_3 + - gmp=6.2.1=h295c915_3 + - gnutls=3.6.15=he1e5248_0 + - intel-openmp=2021.4.0=h06a4308_3561 + - jpeg=9b=h024ee3a_2 + - lame=3.100=h7b6447c_0 + - lcms2=2.12=h3be6417_0 + - ld_impl_linux-64=2.38=h1181459_1 + - libffi=3.4.2=h6a678d5_6 + - libgcc-ng=11.2.0=h1234567_1 + - libgomp=11.2.0=h1234567_1 + - libiconv=1.16=h7f8727e_2 + - libidn2=2.3.2=h7f8727e_0 + - libpng=1.6.37=hbc83047_0 + - libstdcxx-ng=11.2.0=h1234567_1 + - libtasn1=4.16.0=h27cfd23_0 + - libtiff=4.1.0=h2733197_1 + - libunistring=0.9.10=h27cfd23_0 + - libuv=1.44.2=h5eee18b_0 + - libwebp=1.2.0=h89dd481_0 + - lz4-c=1.9.4=h6a678d5_0 + - mkl=2021.4.0=h06a4308_640 + - mkl-service=2.4.0=py38h7f8727e_0 + - mkl_fft=1.3.1=py38hd3c417c_0 + - mkl_random=1.2.2=py38h51133e4_0 + - ncurses=6.4=h6a678d5_0 + - nettle=3.7.3=hbbd107a_1 + - ninja=1.10.2=h06a4308_5 + - ninja-base=1.10.2=hd09550d_5 + - numpy=1.23.5=py38h14f4228_0 + - numpy-base=1.23.5=py38h31eccc5_0 + - openh264=2.1.1=h4ff587b_0 + - openssl=1.1.1t=h7f8727e_0 + - pillow=9.3.0=py38hace64e9_1 + - pip=22.3.1=py38h06a4308_0 + - python=3.8.16=h7a1cb2a_2 + - pytorch=1.8.0=py3.8_cuda10.2_cudnn7.6.5_0 + - readline=8.2=h5eee18b_0 + - setuptools=65.6.3=py38h06a4308_0 + - six=1.16.0=pyhd3eb1b0_1 + - sqlite=3.40.1=h5082296_0 + - tk=8.6.12=h1ccaba5_0 + - torchvision=0.9.0=py38_cu102 + - typing_extensions=4.4.0=py38h06a4308_0 + - wheel=0.38.4=py38h06a4308_0 + - xz=5.2.10=h5eee18b_1 + - zlib=1.2.13=h5eee18b_0 + - zstd=1.4.9=haebb681_0 +prefix: /home/danial/anaconda3/envs/adaface diff --git a/start.py b/start.py new file mode 100644 index 0000000..cc2421a --- /dev/null +++ b/start.py @@ -0,0 +1,24 @@ +#!/usr/bin/python3 +import os +from subprocess import Popen, PIPE + +def run_process_2(cmd, prefix=None, suffix=None, cwd = None, + use_pipe=False, use_shell = False): + if cwd == None: + cwd = os.getcwd() + print("Running process with command: {}".format(cmd),flush=True) + cmd_pcs = cmd.split() + p = Popen(cmd_pcs, cwd = cwd, + stdout = PIPE if use_pipe else None, + stderr = PIPE if use_pipe else None, + shell = use_shell) + return p + +if __name__ == "__main__": + command = 'python inference.py' + all_process = {} + p_id = 0 + p = run_process_2(model) + all_process["P{}".format(p_id)] = [p, True] + p.wait() +