Python开源项目DifFace——人脸重建(Face Restoration),模糊清晰、划痕修复及黑白上色的实践

无论是自己、家人或是朋友、客户的照片,免不了有些是黑白的、被污损的、模糊的,总想着修复一下。作为一个程序员 或者 程序员的家属,当然都有责任满足他们的需求、实现他们的想法。除了这个,学习了本文的成果,或许你还可以用来赚点小钱。

Python Anaconda 的安装、配置等等请参阅:
https://blog.csdn.net/beijinghorn/article/details/134334021icon-default.png?t=N7T8https://blog.csdn.net/beijinghorn/article/details/134334021

7 DifFace

7.1 论文Paper

DifFace: Blind Face Restoration with Diffused Error Contraction
https://arxiv.org/abs/2212.06512
Authors:
Zongsheng Yue,  https://zsyoaoa.github.io/
Chen Change Loy https://www.mmlab-ntu.com/person/ccloy/

⭐ If DifFace is helpful to your images or projects, please help star this repo. Thanks!

7.2 Update


2022.12.19: Add Colab demo google colab logo.
2022.12.17: Add the Hugging Face.
2022.12.13: Create this repo.

7.3 Applications

7.3.1 旧照片修复 Old Photo Enhancement
 


7.3.2 人脸重建 Face Restoration
   


7.4 依赖项Requirements

A suitable conda environment named DifFace can be created and activated with:

conda env create -f environment.yaml
conda activate DifFace

7.5 运行指令 Inference

7.5.1 Face image restoration (cropped and aligned)


python inference_difface.py --aligned --in_path [image folder/image path] --out_path [result folder] --gpu_id [gpu index]

7.5.2 Whole image enhancement


python inference_difface.py --in_path [image folder/image path] --out_path [result folder] --gpu_id [gpu index]

7.6 Training

7.6.1 Prepare data

Download the FFHQ dataset, and resize them into size 512x512.
https://github.com/NVlabs/ffhq-dataset

python datapipe/prepare/face/big2small_face.py --face_dir [Face folder(1024x1024)] --save_dir [Saving folder] --pch_size 512 

Extract the image path into 'datapipe/files_txt/ffhq512.txt'
python datapipe/prepare/face/split_train_val.py --face_dir [Face folder(512x512)] --save_dir [Saving folder] 

Making the testing dataset
python datapipe/prepare/face/make_testing_data.py --files_txt datapipe/files_txt/ffhq512.txt --save_dir [Saving folder]  

7.6.2 Train diffusion model


CUDA_VISIBLE_DEVICES=0,1,2,3 torchrun --standalone --nproc_per_node=4 --nnodes=1 main_diffusion.py --cfg_path configs/training/diffsuion_ffhq512.yaml --save_dir [Logging Folder]  

7.6.3 Train diffused estimator (SwinIR)


CUDA_VISIBLE_DEVICES=0,1,2,3 torchrun --standalone --nproc_per_node=4 --nnodes=1 main_sr.py --cfg_path configs/training/swinir_ffhq512.yaml --save_dir [Logging Folder]  

7.7 权利 License


This project is licensed under NTU S-Lab License 1.0. Redistribution and use should follow this license.
https://github.com/sczhou/CodeFormer/blob/master/LICENSE

7.8 相关知识 Acknowledgement


This project is based on Improved Diffusion Model. Some codes are brought from BasicSR, YOLOv5-face, and FaceXLib. We also adopt Real-ESRGAN to support background image enhancement. Thanks for their awesome works.
该项目基于改进的扩散模型。一些代码来自BasicSR、YOLOv5 face和FaceXLib。我们还采用Real ESRGAN来支持背景图像增强。感谢他们出色的作品。
https://github.com/openai/improved-diffusion
https://github.com/XPixelGroup/BasicSR
https://github.com/deepcam-cn/yolov5-face
https://github.com/xinntao/facexlib
https://github.com/xinntao/Real-ESRGAN

7.9 联系作者 Contact


If you have any questions, please feel free to contact me via [email protected].

7.10 点评


论文。
 

你可能感兴趣的:(C#入门教程,Beginner‘s,Recipes,python,开发语言,人工智能)