Skip to content
 
 

Repository files navigation

icon FaceXLib

PyPI download Open issue Closed issue LICENSE python lint Publish-pip

English | 简体中文


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:   ▶️ Real-ESRGAN▶️ GFPGAN▶️ BasicSR


✨ Functions

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 -

👀 Demo and Tutorials

🔧 Dependencies and Installation

Installation

pip install facexlib

Pre-trained models

It 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.

📜 License and Acknowledgement

This project is released under the MIT license.

📧 Contact

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/result

自定义接口命令行

图片推理命令

1. 人脸检测

python 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

2. 人脸分割(使用face detection + face parsing)

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, 指定--taskparsing

脚本:scripts/run_parsing_folder.sh

3. 皮肤分割 (使用face detection + face parsing, 19类区域,1号区域就是皮肤)

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, 指定--taskskin

脚本:scripts/run_skin_folder.sh

4. 人脸增强(face detection + face parsing)

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, 指定--taskenhance

脚本:scripts/run_enhance_folder.sh

5. 人脸对比度分析 (使用face detection + face parsing)

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 analyze

6. 传统算法肤色检测 (face detection + 传统肤色检测)

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 traditional_skin

视频推理命令行

1. 人脸检测

python video_inference_detection.py --video_path SDR0357_709_1s.mp4 --save_path SDR0357_709_1s_res.mp4

2. 人脸分割(使用face detection + face parsing)

python 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 20

3. 皮肤分割 (使用face detection + face parsing, 19类区域,1号区域就是皮肤)

python 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 20

4. 人脸增强(face detection + face parsing)

python 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 12

5. 人脸对比度分析

python 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指定

About

FaceXlib aims at providing ready-to-use face-related functions based on current STOA open-source methods.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages