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

有关 python anaconda 及运行环境的安装与设置请参阅:

Python开源项目CodeFormer——人脸重建(Face Restoration),模糊清晰、划痕修复及黑白上色的实践icon-default.png?t=N7T8https://blog.csdn.net/beijinghorn/article/details/134334021

1 RESTOREFORMER

https://github.com/wzhouxiff/RestoreFormer

1.1 进化史Updating

  1. 20230915 Update an online demo Huggingface Gradio
  2. 20230915 A more user-friendly and comprehensive inference method refer to our RestoreFormer++
  3. 20230116 For convenience, we further upload the test datasets, including CelebA (both HQ and LQ data), LFW-Test, CelebChild-Test, and Webphoto-Test, to OneDrive and BaiduYun.
  4. 20221003 We provide the link of the test datasets.
  5. 20220924 We add the code for metrics in scripts/metrics.

1.2 论文RestoreFormer


This repo includes the source code of the paper: "RestoreFormer: High-Quality Blind Face Restoration from Undegraded Key-Value Pairs" (CVPR 2022) by Zhouxia Wang, Jiawei Zhang, Runjian Chen, Wenping Wang, and Ping Luo.

RestoreFormer tends to explore fully-spatial attentions to model contextual information and surpasses existing works that use local operators. It has several benefits compared to prior arts. First, it incorporates a multi-head coross-attention layer to learn fully-spatial interations between corrupted queries and high-quality key-value pairs. Second, the key-value pairs in RestoreFormer are sampled from a reconstruction-oriented high-quality dictionary, whose elements are rich in high-quality facial features specifically aimed for face reconstruction.

1.3 运行环境Environment


python>=3.7
pytorch>=1.7.1
pytorch-lightning==1.0.8
omegaconf==2.0.0
basicsr==1.3.3.4
Warning Different versions of pytorch-lightning and omegaconf may lead to errors or different results.

1.4 数据集与模型Preparations of dataset and models


1.4.1 Dataset:

Training data: Both HQ Dictionary and RestoreFormer in our work are trained with FFHQ which attained from FFHQ repository. The original size of the images in FFHQ are 1024x1024. We resize them to 512x512 with bilinear interpolation in our work. Link this dataset to ./data/FFHQ/image512x512.

https://pan.baidu.com/s/1SjBfinSL1F-bbOpXiD0nlw?pwd=nren

1.4.2 测试数据Test data:


CelebA-Test-HQ: OneDrive; BaiduYun(code mp9t)
https://pan.baidu.com/s/1tMpxz8lIW50U8h00047GIw?pwd=mp9t

CelebA-Test-LQ: OneDrive; BaiduYun(code 7s6h)
https://pan.baidu.com/s/1y6ZcQPCLyggj9VB5MgoWyg?pwd=7s6h

LFW-Test: OneDrive; BaiduYun(code 7fhr). Note that it was align with dlib.
https://pan.baidu.com/s/1UkfYLTViL8XVdZ-Ej-2G9g?pwd=7fhr

CelebChild: OneDrive; BaiduYun(code rq65)
https://pan.baidu.com/s/1pGCD4TkhtDsmp8emZd8smA?pwd=rq65

WepPhoto-Test: OneDrive; BaiduYun(code nren)
https://pan.baidu.com/s/1SjBfinSL1F-bbOpXiD0nlw?pwd=nren

Model: Both pretrained models used for training and the trained model of our RestoreFormer can be attained from OneDrive or BaiduYun(code x6nn). Link these models to ./experiments.

https://pan.baidu.com/s/1EO7_1dYyCuORpPNosQgogg?pwd=x6nn

1.5 测试Test


sh scripts/test.sh

1.6 自训练Training


sh scripts/run.sh

Note.

The first stage is to attain HQ Dictionary by setting conf_name in scripts/run.sh to 'HQ_Dictionary'.
The second stage is blind face restoration. You need to add your trained HQ_Dictionary model to ckpt_path in config/RestoreFormer.yaml and set conf_name in scripts/run.sh to 'RestoreFormer'.
Our model is trained with 4 V100 GPUs.

1.7 度量 Metrics

sh scripts/metrics/run.sh

Note.
You need to add the path of CelebA-Test dataset in the script if you want get IDD, PSRN, SSIM, LIPIS.

1.8 引用 Citation


@article{wang2022restoreformer,
  title={RestoreFormer: High-Quality Blind Face Restoration from Undegraded Key-Value Pairs},
  author={Wang, Zhouxia and Zhang, Jiawei and Chen, Runjian and Wang, Wenping and Luo, Ping},
  booktitle={The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
  year={2022}
}

1.9 知识 Acknowledgement

We thank everyone who makes their code and models available, especially Taming Transformer, basicsr, and GFPGAN.

1.10 联系 Contact


For any question, feel free to email wzhoux@connect.hku.hk or zhouzi1212@gmail.com.

2 RESTOREFORMER++

https://github.com/wzhouxiff/RestoreFormerPlusPlus


2.1 进化史ToDo List


20230915 Update an online demo Huggingface Gradio
20230915 Provide a user-friendly method for inference.
It is avaliable for background SR with RealESRGAN.
basicsr should be upgraded to 1.4.2.
20230914 Upload model
20230914 Realse Code
20221120 Introducing the project.

2.2 论文RestoreFormer++


This repo is a official implementation of "RestoreFormer++: Towards Real-World Blind Face Restoration from Undegraded Key-Value Paris".
https://arxiv.org/pdf/2308.07228.pdf

RestoreFormer++ is an extension of our RestoreFormer. It proposes to restore a degraded face image with both fidelity and realness by using the powerful fully-spacial attention mechanisms to model the abundant contextual information in the face and its interplay with our reconstruction-oriented high-quality priors. Besides, it introduces an extending degrading model (EDM) that contains more realistic degraded scenarios for training data synthesizing, which helps to enhance its robustness and generalization towards real-world scenarios. Our results compared with the state-of-the-art methods and performance with/without EDM are in following:

RestoreFormer++是RestoreFormer的扩展。它提出了利用强大的全空间注意机制来模拟人脸中丰富的上下文信息及其与我们面向重构的高质量先验的相互作用,以保真度和真实度恢复退化的人脸图像。此外,它还引入了一个扩展的退化模型(EDM),该模型包含更真实的退化场景,用于训练数据合成,这有助于增强其鲁棒性和对真实场景的泛化。我们的结果与最先进的方法和性能有/没有EDM的比较如下:

2.3 运行环境Environment


python>=3.7
pytorch>=1.7.1
pytorch-lightning==1.0.8
omegaconf==2.0.0
basicsr==1.3.3.4 basicsr>=1.4.2
realesrgan==0.3.0

Warning Different versions of pytorch-lightning and omegaconf may lead to errors or different results.
警告:不同版本的pytorch-lightning和omegaconf可能导致错误或不同的结果。

2.4 数据集与模型Preparations of dataset and models

Dataset:

Training data: Both ROHQD and RestoreFormer++ in our work are trained with FFHQ which attained from FFHQ repository. The original size of the images in FFHQ are 1024x1024. We resize them to 512x512 with bilinear interpolation in our work. Link this dataset to ./data/FFHQ/image512x512.
https://github.com/NVlabs/ffhq-dataset
Test data: CelebA-Test, LFW-Test, WebPhoto-Test, and CelebChild-Test
https://pan.baidu.com/s/1iUvBBFMkjgPcWrhZlZY2og?pwd=test
http://vis-www.cs.umass.edu/lfw/#views
https://xinntao.github.io/projects/gfpgan
训练数据:在我们的工作中,ROHQD和RestoreFormer++都是用FFHQ库获得的FFHQ训练的。FFHQ中的图像的原始大小是1024x1024。在我们的工作中,我们用双线性插值将它们调整为512x512。将此数据集链接到./data/FFHQ/image512x512。

Model: Both pretrained models used for training and the trained model of our RestoreFormer and RestoreFormer++ can be attained from Google Driver. Link these models to ./experiments.
https://connecthkuhk-my.sharepoint.com/:f:/g/personal/wzhoux_connect_hku_hk/EkZhGsLBtONKsLlWRmf6g7AB_VOA_6XAKmYUXLGKuNBsHQ?e=ic2LPl
模型:用于训练的预训练模型和我们的RestoreFormer和RestoreFormer++的训练模型都可以从谷歌盘中获得。将这些模型链接(存放)到:/experiments 文件夹。

2.5 快速指南Quick Inference


python inference.py -i data/aligned -o results/RF++/aligned -v RestoreFormer++ -s 2 --aligned --save
python inference.py -i data/raw -o results/RF++/raw -v RestoreFormer++ -s 2 --save
python inference.py -i data/aligned -o results/RF/aligned -v RestoreFormer -s 2 --aligned --save
python inference.py -i data/raw -o results/RF/raw -v RestoreFormer -s 2 --save

Note: Related codes are borrowed from GFPGAN.
https://github.com/TencentARC/GFPGAN

2.6 测试Test


sh scripts/test.sh
scripts/test.sh

exp_name='RestoreFormer'
exp_name='RestoreFormerPlusPlus'

root_path='experiments'
out_root_path='results'
align_test_path='data/aligned'
# unalign_test_path='data/raw'
tag='test'

outdir=$out_root_path'/'$exp_name'_'$tag

if [ ! -d $outdir ];then
    mkdir -m 777 $outdir
fi

CUDA_VISIBLE_DEVICES=0 python -u scripts/test.py \
--outdir $outdir \
-r $root_path'/'$exp_name'/last.ckpt' \
-c 'configs/'$exp_name'.yaml' \
--test_path $align_test_path \
--aligned

This codebase is available for both RestoreFormer and RestoreFormerPlusPlus. Determinate the specific model with exp_name.
这个代码库可用于RestoreFormer和RestoreFormer++。使用exp_name确定特定的模型。
Setting the model path with root_path
使用root_path设置模型路径
Restored results are save in out_root_path
恢复的结果将保存在out_root_path中
Put the degraded face images in test_path
将退化的人脸图像放入test_path中
If the degraded face images are aligned, set --aligned, else remove it from the script. The provided test images in data/aligned are aligned, while images in data/raw are unaligned and contain several faces.
如果退化的人脸图像对齐,设置对齐,否则将其从脚本中删除。所提供的数据/对齐中的测试图像是对齐的,而数据/原始中的图像是未对齐的,并且包含多个面。


2.7 自我训练Training


sh scripts/run.sh

scripts/run.sh

export BASICSR_JIT=True

# For RestoreFormer
# conf_name='HQ_Dictionary'
# conf_name='RestoreFormer'

# For RestoreFormer++
conf_name='ROHQD'
conf_name='RestoreFormerPlusPlus'

# gpus='0,1,2,3,4,5,6,7'
# node_n=1
# ntasks_per_node=8

root_path='PATH_TO_CHECKPOINTS'

gpus='0,'
node_n=1
ntasks_per_node=1

gpu_n=$(expr $node_n \* $ntasks_per_node)

python -u main.py \
--root-path $root_path \
--base 'configs/'$conf_name'.yaml' \
-t True \
--postfix $conf_name'_gpus'$gpu_n \
--gpus $gpus \
--num-nodes $node_n \
--random-seed True \

This codebase is available for both RestoreFormer and RestoreFormerPlusPlus. Determinate the training model with conf_name. 'HQ_Dictionary' and 'RestoreFormer' are for RestoreFormer, while 'ROHQD' and 'RestoreFormerPlusPlus' are for RestoreFormerPlusPlus.
While training 'RestoreFormer' or 'RestoreFormerPlusPlus', 'ckpt_path' in the corresponding configure files in configs/ sholud be updated with the path of the trained model of 'HQ_Dictionary' or 'ROHQD'.
这个代码库可用于RestoreFormer和RestoreFormer++。用conf_name确定训练模型。“HQ_Dictionary”和“RestoreFormer”用于RestoreFormer,而“ROHQD”和“RestoreFormer”用于RestoreFormer。
在训练“RestoreFormer”或“RestoreFormer++”时,配置中相应配置文件中的“ckpt_path”将更新训练模型的“HQ_Dictionary”或“ROHQD”的路径。


2.8 指标Metrics


sh scripts/metrics/run.sh
Note.

You need to add the path of CelebA-Test dataset in the script if you want get IDD, PSRN, SSIM, LIPIS.
Related metric models are in ./experiments/pretrained_models/
如果您想获得IDD,PSRN,SSIM,LIPIS,您需要在脚本中添加CelebA-测试数据集的路径。
相关的度量模型在。/experiments/pretrained_models/

2.9 引用Citation


@article{wang2023restoreformer++,
  title={RestoreFormer++: Towards Real-World Blind Face Restoration from Undegraded Key-Value Paris},
  author={Wang, Zhouxia and Zhang, Jiawei and Chen, Tianshui and Wang, Wenping and Luo, Ping},
  booktitle={IEEE Transactions on Pattern Analysis and Machine Intelligence (T-PAMI)},
  year={2023}
}

@article{wang2022restoreformer,
  title={RestoreFormer: High-Quality Blind Face Restoration from Undegraded Key-Value Pairs},
  author={Wang, Zhouxia and Zhang, Jiawei and Chen, Runjian and Wang, Wenping and Luo, Ping},
  booktitle={The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
  year={2022}
}

2.10 联系Contact


For any question, feel free to email wzhoux@connect.hku.hk or zhouzi1212@gmail.com.
如有任何问题,请随时发邮件至wzhoux@connect.hku.hk或zhouzi1212@gmail.com。

这两个代码都写的不好,效率低,效果差,有点应付论文的意思。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/131352.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

评国青、优青、杰青,到底需要什么级别的文章?五篇代表作如何选?

一到年底就听同事们讨论到底申报“杰青”、“优青”还是“国青”,那么,“杰青”到底是什么呢?它和“优青”、“国青”又有什么区别呢? 杰青,全称“国家杰出青年基金获得者”,是国家自然科学基金里人才资助…

条件渲染-if/hidden

1.条件渲染的方法 1.1 wx:if方法(少用) block只是一个容器,容器内的都用于if判断 1.2 hidden方法 注:view要小写,否则不生效 1.3方法对比

C++ 编译与链接过程

案例讲解 有 main.cpp 和 add.cpp 2个文件&#xff0c;add.cpp中实现add_func函数&#xff0c;main.cpp文件中需要使用add_func函数。 demo&#xff1a; // main.cpp文件 #include <iostream>int add_func(int a, int b);int main() {int a 10;int b 10;int ret ad…

KM云仓——限制用户无法提现?资金盘?

KM云仓一个打着跨境电商的资金盘 最近几年跨境电商越来越火&#xff0c;各种短视频平台上也有不少人推跨境电商&#xff0c;宣传中国几块钱的东西&#xff0c;挂到美国能买几十刀甚至一百多刀&#xff0c;非常的暴力&#xff0c;且资金投入非常少&#xff0c;吸引力许多的宝妈…

快块手多功能全自动引流软件-引流工具-引流脚本-自动引流技术功能介绍

脚本功能&#xff1a; 功能1_养号功能 功能2_评论区关注 功能3_评论区私信 功能4_评论区用户作品评论 功能5_评论区点赞 功能6_粉丝回关 功能7_自己粉丝私信 功能8_已关私信 功能9_好友私信 功能10_关键词搜索关注 功能11_关键词搜索私信 功能12_搜索ID关注 功能13_搜索ID私信…

Linux学习第二枪(yum,vim,g++/gcc,makefile的使用)

前言&#xff1a;在我的上一篇Linux博客我已经讲了基础指令和权限&#xff0c;现在我们来学习如何在Linux上运行和执行代码 一&#xff0c;yum yum是Linux中的软件包管理器&#xff0c;软件包是有人一些人写好的代码和程序作出软件包放到服务器上&#xff0c;我们使用yum就能…

响应式少儿舞蹈培训网站模板源码

模板信息&#xff1a; 模板编号&#xff1a;6903 模板编码&#xff1a;UTF8 模板颜色&#xff1a;橙色 模板分类&#xff1a;学校、教育、培训、科研 适合行业&#xff1a;培训机构类企业 模板介绍&#xff1a; 本模板自带eyoucms内核&#xff0c;无需再下载eyou系统&#xf…

uni.getLocation() 微信小程序 线上获取失败

开发版,体验版,用此方法都可以正确获取定位,但是在小程序的线上,总是获取失败 参考:uni-app微信小程序uni.getLocation获取位置&#xff1b;authorize scope.userLocation需要在app.json中声明permission&#xff1b;小程序用户拒绝授权后重新授权-CSDN博客 uniapp 中的 uni.…

【数据结构】树与二叉树(七):二叉树的遍历(先序、中序、后序及其C语言实现)

文章目录 5.2.1 二叉树二叉树性质引理5.1&#xff1a;二叉树中层数为i的结点至多有 2 i 2^i 2i个&#xff0c;其中 i ≥ 0 i \geq 0 i≥0。引理5.2&#xff1a;高度为k的二叉树中至多有 2 k 1 − 1 2^{k1}-1 2k1−1个结点&#xff0c;其中 k ≥ 0 k \geq 0 k≥0。引理5.3&…

leetcode(力扣) 207. 课程表1+2(图的构造与遍历,清晰思路,完整模拟)

文章目录 题目描述思路分析完整代码 题目描述 你这个学期必须选修 numCourses 门课程&#xff0c;记为 0 到 numCourses - 1 。 在选修某些课程之前需要一些先修课程。 先修课程按数组 prerequisites 给出&#xff0c;其中 prerequisites[i] [ai, bi] &#xff0c;表示如果要学…

网易云音乐未登录接口返回301

网易云音乐 NodeJS 版 API (neteasecloudmusicapi.js.org) 上面是网易云音乐的官方API接口文档 当我调用接口发送请求的时候部分接口数据是需要登录之后进行获取的&#xff0c;但是当我发送请求的时候原生js项目中的跨端问题是比较难解决的。 遇到的问题&#xff1a;跨端请求…

超详细!Linux内核内存规整详解

1.前言 伙伴系统作为内核最基础的物理页内存分配器&#xff0c;具有高效、实现逻辑简介等优点&#xff0c;其原理页也尽可能降低内存外部碎片产生&#xff0c;但依然无法杜绝碎片问题。外部碎片带来的最大影响就是内存足够&#xff0c;但是却无法满足内存分配需求&#xff0c;如…

35 字段类型不匹配 影响 使用索引?

前言 这是一个经常能够看到的问题, 又或者 经常在面试中碰到 如果 索引字段类型 不匹配, 然后 不会使用索引 这里 我们来看一下 具体的情况 测试表结构如下 CREATE TABLE tz_test (id int(11) unsigned NOT NULL AUTO_INCREMENT,field1 varchar(128) DEFAULT NULL,PRIMA…

开放领域问答机器人1

开放领域问答机器人是一种智能机器人&#xff0c;它不受限制&#xff0c;可以回答任何问题。这种机器人主要通过自然语言处理技术来理解用户的问题&#xff0c;并从大量的数据中获取相关信息&#xff0c;以提供准确的答案。它的应用领域广泛&#xff0c;包括客户服务、教育、医…

GS3661V1 3.7升压5V 3A SOT23-5封装 外置MOS 升压芯片 单节锂电升压5V 2.5-3A

GS3661V1 3.7升压5V 3A SOT23-5 外置MOS 升压芯片 单节锂电升压5V 2.5-3A

贝锐向日葵亮相云栖大会,携手无影推出全新“云桌面”功能

2023年10月31日-11月2日&#xff0c;一年一度的云栖大会如期举办&#xff0c;本届云栖大会主题为“计算&#xff0c;为了无法计算的价值”&#xff0c;国民级远程控制品牌“贝锐向日葵”亮相云栖大会&#xff0c;参与了以“云电脑”为主题的聚合话题活动。 活动现场&#xff0c…

Vue3组件

组件&#xff08;Component&#xff09;是 Vue.js 最强大的功能之一。 组件可以扩展 HTML 元素&#xff0c;封装可重用的代码。 组件系统让我们可以用独立可复用的小组件来构建大型应用&#xff0c;几乎任意类型的应用的界面都可以抽象为一个组件树&#xff1a; 每个 Vue 应用…

基于SSM的食用菌菌棒溯源系统

末尾获取源码 开发语言&#xff1a;Java Java开发工具&#xff1a;JDK1.8 后端框架&#xff1a;SSM 前端&#xff1a;Vue 数据库&#xff1a;MySQL5.7和Navicat管理工具结合 服务器&#xff1a;Tomcat8.5 开发软件&#xff1a;IDEA / Eclipse 是否Maven项目&#xff1a;是 目录…

广告算法资料汇总【建设中】

业内大佬 阿里妈妈技术 张俊林 王喆 萧瑟 朱小强 综合 付海军&#xff1a;基于互联网广告发展演变和思考&#xff08;附视频讲解PPT&#xff09; 广告算法工程师入门_广告与算法的博客-CSDN博客 广告算法学习笔记 20万、50万、100万的算法工程师&#xff0c;到底有什么区别…

Linux编辑器---vim的使用

Vim是一个高度可配置的文本编辑器&#xff0c;它是操作Linux的一款利器&#xff0c;旨在高效地创建和更改任何类型的文本。这款编辑器起源于"vi"&#xff0c;并在此基础上发展出了众多新的特性。Vim被普遍推崇为类Vi编辑器中最好的一个&#xff0c;事实上真正的劲敌来…