facexlib aims at providing ready-to-use face-related functions based on current SOTA open-source methods.
Only PyTorch reference codes are available. For training or fine-tuning, please refer to their original repositories listed below.
Note that we just provide a collection of these algorithms. You need to refer to their original LICENCEs for your intended use.
If facexlib is helpful in your projects, please help to ⭐ this repo. Thanks😊
Other recommended projects:
| Function | Sources | Original LICENSE |
|---|---|---|
| Detection | Pytorch_Retinaface | MIT |
| Alignment | AdaptiveWingLoss | Apache 2.0 |
| Recognition | InsightFace_Pytorch | MIT |
| Parsing | face-parsing.PyTorch | MIT |
| Matting | MODNet | CC 4.0 |
| Headpose | deep-head-pose | Apache 2.0 |
| Tracking | SORT | GPL 3.0 |
| Assessment | hyperIQA | - |
| Utils | Face Restoration Helper | - |
- Python >= 3.7 (Recommend to use Anaconda or Miniconda)
- PyTorch >= 1.7
- Option: NVIDIA GPU + CUDA
pip install facexlibIt will automatically download pre-trained models at the first inference.
If your network is not stable, you can download in advance (may with other download tools), and put them in the folder: PACKAGE_ROOT_PATH/facexlib/weights.
This project is released under the MIT license.
If you have any question, open an issue or email xintao.wang@outlook.com.
# 1. detection
python inference_detection.py --img_path /mnt/ec-data2/ivs/1080p/zyh/testset/sr/yuexia_src/yuexia3_madong_face.png --save_path /data/yh/FACE_2024/facexlib/result/yuexia3_madong_face_detect.png
# 2. matting
python inference_matting.py --img_path /mnt/ec-data2/ivs/1080p/zyh/testset/sr/yuexia_src/yuexia3_madong_face.png --save_path /data/yh/FACE_2024/facexlib/result/yuexia3_madong_face_mat.png
# 3. alignment(关键点) 需要人脸小图
python inference_alignment.py --img_path /data/yh/FACE_2024/facexlib/result/yuexia3_madong_face_cvwarp_00.png --save_path /data/yh/FACE_2024/facexlib/result/yuexia3_madong_face_align.png
# 4. parsing (人脸解析分割成更精细的部分) 需要人脸小图
# bisenet: 效果比较好
python inference_parsing.py --input /data/yh/FACE_2024/facexlib/result/yuexia3_madong_face_cvwarp_00.png --output /data/yh/FACE_2024/facexlib/result
# parsenet: 效果不好
python inference_parsing_parsenet.py --input /data/yh/FACE_2024/facexlib/result/yuexia3_madong_face_cvwarp_00.png --output /data/yh/FACE_2024/facexlib/resultpython inference/inference_detection.py --img_path /mnt/ec-data2/ivs/1080p/zyh/testset/sr/yuexia_src/yuexia3_madong_face.png --save_path /data/yh/FACE_2024/facexlib/result/yuexia3_madong_face_detect.png --half --output_txt --target_size 512 --max_size 1024参数介绍:
--half:是否使用half精度--output_txt:是否输出txt文件, txt文件与图片同名,内容为检测到的人脸信息,每一行为一个人脸的信息,包括人脸的置信度和坐标,坐标为左上角和右下角的坐标,例如'face 1.0 937 185 1150 467'--target_size:将图像的短边缩放到的目标大小--max_size:缩放后的最大尺寸,如果缩放完之后,图像的长边大于max_size,则再次将其缩放到max_size 如果不缩放需要使用'--use_origin_size'参数
脚本:scripts/run_detection_folder.sh
python inference/face_process.py --img_path /mnt/ec-data2/ivs/1080p/zyh/testset/sr/yuexia_src/yuexia3_madong_face.png --save_path /data/yh/FACE_2024/facexlib/result/yuexia3_madong_face_parsing.jpg --half --output_txt --target_size 512 --max_size 1024 --task parsing使用inference/face_process.py, 指定--task为parsing
脚本:scripts/run_parsing_folder.sh
python inference/face_process.py --img_path /mnt/ec-data2/ivs/1080p/zyh/testset/sr/yuexia_src/yuexia3_madong_face.png --save_path /data/yh/FACE_2024/facexlib/result/yuexia3_madong_face_skin.jpg --half --output_txt --target_size 512 --max_size 1024 --task skin使用inference/face_process.py, 指定--task为skin
脚本:scripts/run_skin_folder.sh
python inference/face_process.py --img_path /mnt/ec-data2/ivs/1080p/zyh/testset/sr/yuexia_src/yuexia3_madong_face.png --save_path /data/yh/FACE_2024/facexlib/result/yuexia3_madong_face_enhance.png --half --output_txt --target_size 512 --max_size 1024 --task enhance使用inference/face_process.py, 指定--task为enhance
脚本:scripts/run_enhance_folder.sh
python inference/face_process.py --img_path /mnt/ec-data2/ivs/1080p/zyh/testset/sr/yuexia_src/yuexia3_madong_face.png --save_path /data/yh/FACE_2024/facexlib/result/yuexia3_madong_face_analyze.png --half --output_txt --target_size 512 --max_size 1024 --task analyzepython inference/face_process.py --img_path /mnt/ec-data2/ivs/1080p/zyh/testset/sr/yuexia_src/yuexia3_madong_face.png --save_path /data/yh/FACE_2024/facexlib/result/yuexia3_madong_face_analyze.png --half --output_txt --target_size 512 --max_size 1024 --task traditional_skinpython video_inference_detection.py --video_path SDR0357_709_1s.mp4 --save_path SDR0357_709_1s_res.mp4python inference/video_face_process.py --video_path /mnt/ec-data2/ivs/1080p/zyh/hdr_dirty_face/sdr/jialin/SDR2822_709.mp4 --save_path /mnt/ec-data2/ivs/1080p/zyh/SDR2822_709_parsing.mp4 --task parsing --qp 20python inference/video_face_process.py --video_path /mnt/ec-data2/ivs/1080p/zyh/hdr_dirty_face/sdr/jialin/SDR2822_709.mp4 --save_path /mnt/ec-data2/ivs/1080p/zyh/SDR2822_709_skin.mp4 --task skin --qp 20python inference/video_face_process.py --video_path /mnt/ec-data2/ivs/1080p/zyh/hdr_dirty_face/sdr/jialin/SDR2822_709.mp4 --save_path /mnt/ec-data2/ivs/1080p/zyh/SDR2822_709_enhance.mp4 --task enhance --qp 12python inference/video_face_process.py --video_path /mnt/ec-data2/ivs/1080p/zyh/hdr_dirty_face/sdr/jialin/SDR2822_709.mp4 --save_path /mnt/ec-data2/ivs/1080p/zyh/SDR2822_709_enhance.mp4 --qp 20 --task analyze人脸分割、皮肤分割、人脸增强和人脸对比度分析都是使用的video_face_process.py, 通过--task指定