Skip to content

Latest commit

 

History

History
113 lines (78 loc) · 2.16 KB

README.md

File metadata and controls

113 lines (78 loc) · 2.16 KB

Face Detection Development

This repository is dedicated to face detection development. It supports training, evaluation, and ONNX model conversion. The first implementation included in this repo is SCRFD.

Environment setup

MacOS

  • Pyenv

  • Set up xz for pyenv to install Python 3.10.16

    brew install xz
    echo 'export PYTHON_CONFIGURE_OPTS="--with-lzma=$(brew --prefix xz)' > ~/.zshrc
    exec $SHELL
    pyenv install 3.10.16
    pyenv virtualenv 3.10.16 face_detection_dev
    pyenv activate face_detection_dev
  • Python packages

    pip install wheel
    pip install torch==2.4.1 torchvision # must fix for mps bug, see https://github.com/pytorch/pytorch/issues/142344
    MAX_JOBS=4 MMCV_WITH_OPS=1 pip install git+https://github.com/open-mmlab/[email protected]
    pip install -r docker/requirements_macos.txt

Linux

  • Pyenv

    pyenv install 3.10.16
    pyenv virtualenv 3.10.16 face_detection_dev
    pyenv activate face_detection_dev
  • Python packages

    pip install wheel
    pip install torch==2.5.1 torchvision
    MAX_JOBS=4 MMCV_WITH_OPS=1 pip install git+https://github.com/open-mmlab/[email protected]
    pip install -r docker/requirements_linux.txt

Docker

  • Build Docker image

    cd docker
    bash build.sh
    cd -
  • Run Docker container

    bash docker/run_docker.sh $CMD

Train

prepare dataset

We use gdown to download the dataset. Please install it first.

pip install gdown

Then download the dataset and untar it.

gdown 1nr5QhnDIeiMApzK_fjYsh0BjD3_OwPgw
tar cvf face_detection.tar

without docker

python -u train.py ${config}

with docker

bash docker/run_docker.sh python train.py ${config}

To onnx

ipython -- torch2onnx.py --config ${config} --ckpt_fpath ${ckpt_fpath} --onnx_fpath ${onnx_fpath}

Benchmarks

Widerface Evaluation

ipython -- benchmark/widerface.py --onnx_fpath ${onnx_fpath}

NIST Evaluation

ipython -- benchmark/nist.py --onnx_fpath ${onnx_fpath}