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

news2024/10/6 8:34:39

Python Anaconda 的安装等请参阅:

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

VQFR也是 腾讯 LAB 的作品,比较忠于德国 VQGAN 思想的,速度虽然慢一点,效果凑合。用于修正国人脸,效果一般。代码比较精炼,笔者用 Python2Sharp 转为 C++/C# 复现,速度与效果尚可。

6 VQFR (ECCV 2022 Oral)


https://github.com/TencentARC/VQFR
https://github.com/TencentARC/VQFR/releases  模型下载

download Open issue Closed issue LICENSE google colab logo

Colab Demo for VQFR
https://colab.research.google.com/drive/1Nd_PUrHaYmeEAOF5f_Zi0VuOxlJ62gLr?usp=sharing
Online demo: Replicate.ai (may need to sign in, return the whole image)
https://replicate.com/tencentarc/vqfr

6.1 进化史Updates


2022.10.16 Clean research codes & Update VQFR-v2. In this version, we emphasize the restoration quality of the texture branch and balance fidelity with user control. google colab logo
Support enhancing non-face regions (background) with Real-ESRGAN.
The Colab Demo of VQFR is created.
The training/inference codes and pretrained models in paper are released.

This paper aims at investigating the potential and limitation of Vector-Quantized (VQ) dictionary for blind face restoration.
We propose a new framework VQFR – incoporating the Vector-Quantized Dictionary and the Parallel Decoder. Compare with previous arts, VQFR produces more realistic facial details and keep the comparable fidelity.

VQFR: Blind Face Restoration with Vector-Quantized Dictionary and Parallel Decoder
[Paper]   [Project Page]   [Video]   [B站]   [Poster]   [Slides]
Yuchao Gu, Xintao Wang, Liangbin Xie, Chao Dong, Gen Li, Ying Shan, Ming-Ming Cheng
Nankai University; Tencent ARC Lab; Tencent Online Video; Shanghai AI Laboratory;
Shenzhen Institutes of Advanced Technology, Chinese Academy of Sciences

Release 

去这里下载模型。

6.2 依赖项与安装Dependencies and Installation


6.2.1 依赖项Dependencies


Python >= 3.7 (Recommend to use Anaconda or Miniconda)
PyTorch >= 1.7
Option: NVIDIA GPU + CUDA
Option: Linux

6.2.2 安装Installation


6.2.2.1 Clone repo

git clone https://github.com/TencentARC/VQFR.git
cd VQFR

6.2.2.2 Install dependent packages

# Build VQFR with extension
pip install -r requirements.txt
VQFR_EXT=True python setup.py develop

# Following packages are required to run demo.py

# Install basicsr - https://github.com/xinntao/BasicSR
pip install basicsr

# Install facexlib - https://github.com/xinntao/facexlib
# We use face detection and face restoration helper in the facexlib package
pip install facexlib

# If you want to enhance the background (non-face) regions with Real-ESRGAN,
# you also need to install the realesrgan package
pip install realesrgan

6.3 快速指南Quick Inference


Download pre-trained VQFRv1/v2 models [Google Drive].
https://drive.google.com/drive/folders/1lczKYEbARwe27FJlKoFdng7UnffGDjO2?usp=sharing

https://github.com/TencentARC/VQFR/releases/download/v2.0.0/VQFR_v2.pth
https://github.com/TencentARC/VQFR/releases/download/v2.0.0/VQ_Codebook_FFHQ512_v2.pth

Inference

# for real-world image
python demo.py -i inputs/whole_imgs -o results -v 2.0 -s 2 -f 0.1

# for cropped face
python demo.py -i inputs/cropped_faces/ -o results -v 2.0 -s 1 -f 0.1 --aligned
Usage: python demo.py -i inputs/whole_imgs -o results -v 2.0 -s 2 -f 0.1 [options]...

  -h                   show this help
  -i input             Input image or folder. Default: inputs/whole_imgs
  -o output            Output folder. Default: results
  -v version           VQFR model version. Option: 1.0. Default: 1.0
  -f fidelity_ratio    VQFRv2 model supports user control fidelity ratio, range from [0,1]. 0 for the best quality and 1 for the best fidelity. Default: 0
  -s upscale           The final upsampling scale of the image. Default: 2
  -bg_upsampler        background upsampler. Default: realesrgan
  -bg_tile             Tile size for background sampler, 0 for no tile during testing. Default: 400
  -suffix              Suffix of the restored faces
  -only_center_face    Only restore the center face
  -aligned             Input are aligned faces
  -ext                 Image extension. Options: auto | jpg | png, auto means using the same extension as inputs. Default: auto

6.4 自我训练Training


We provide the training codes for VQFR (used in our paper).

Dataset preparation: FFHQ
https://github.com/NVlabs/ffhq-dataset

Download lpips weights [Google Drive] into experiments/pretrained_models/
https://drive.google.com/drive/folders/1weXfn5mdIwp2dEfDbNNUkauQgo8fx-2D?usp=sharing

Codebook Training

Pre-train VQ codebook on FFHQ datasets.
python -m torch.distributed.launch --nproc_per_node=8 --master_port=2022 vqfr/train.py -opt options/train/VQGAN/train_vqgan_v1_B16_800K.yml --launcher pytorch
Or download our pretrained VQ codebook Google Drive and put them in the experiments/pretrained_models folder.
https://drive.google.com/drive/folders/1lczKYEbARwe27FJlKoFdng7UnffGDjO2?usp=sharing

Restoration Training

Modify the configuration file options/train/VQFR/train_vqfr_v1_B16_200K.yml accordingly.

Training

python -m torch.distributed.launch --nproc_per_node=8 --master_port=2022 vqfr/train.py -opt options/train/VQFR/train_vqfr_v1_B16_200K.yml --launcher pytorch

6.5 评估Evaluation


We evaluate VQFR on one synthetic dataset CelebA-Test, and three real-world datasets LFW-Test, CelebChild and Webphoto-Test. For reproduce our evaluation results, you need to perform the following steps:

1 Download testing datasets (or VQFR results) by the following links:
Name    Datasets    Short Description    Download    VQFR Results
Testing Datasets    CelebA-Test(LQ/HQ)    3000 (LQ, HQ) synthetic images for testing    Google Drive    Google Drive
LFW-Test(LQ)    1711 real-world images for testing
CelebChild(LQ)    180 real-world images for testing
Webphoto-Test(LQ)    469 real-world images for testing

2 Install related package and download pretrained models for different metrics:

    # LPIPS
    pip install lpips

    # Deg.
    cd metric_paper/
    git clone https://github.com/ronghuaiyang/arcface-pytorch.git
    mv arcface-pytorch/ arcface/
    rm arcface/config/__init__.py arcface/models/__init__.py

    # put pretrained models of different metrics to "experiments/pretrained_models/metric_weights/"

Metrics    Pretrained Weights    Download
FID    inception_FFHQ_512.pth    Google Drive
Deg    resnet18_110.pth
LMD    alignment_WFLW_4HG.pth

Generate restoration results:
Specify the dataset_lq/dataset_gt to the testing dataset root in test_vqfr_v1.yml.

Then run the following command:

    python vqfr/test.py -opt options/test/VQFR/test_vqfr_v1.yml

Run evaluation:
    # LPIPS|PSNR/SSIM|LMD|Deg.
    python metric_paper/[calculate_lpips.py|calculate_psnr_ssim.py|calculate_landmark_distance.py|calculate_cos_dist.py]
    -restored_folder folder_to_results -gt_folder folder_to_gt

    # FID|NIQE
    python metric_paper/[calculate_fid_folder.py|calculate_niqe.py] -restored_folder folder_to_results

6.6 权利License


VQFR is released under Apache License Version 2.0.


6.7 知识Acknowledgement


Thanks to the following open-source projects:

Taming-transformers
https://github.com/CompVis/taming-transformers
GFPGAN
https://github.com/TencentARC/GFPGAN
DistSup
https://github.com/distsup/DistSup

6.8 引用Citation


@inproceedings{gu2022vqfr,
  title={VQFR: Blind Face Restoration with Vector-Quantized Dictionary and Parallel Decoder},
  author={Gu, Yuchao and Wang, Xintao and Xie, Liangbin and Dong, Chao and Li, Gen and Shan, Ying and Cheng, Ming-Ming},
  year={2022},
  booktitle={ECCV}
}

6.9 联系Contact


If you have any question, please email yuchaogu9710@gmail.com.

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

无代码:解决非程序员的开发难题

最近,有个小型企业的负责人找上我,说他公司需要一个内部管理系统,来提高工作和协作效率,但他没有编程经验,也不打算花费大量时间和金钱雇佣专业的开发团队,他问我有没有什么解决方案。 针对这个问题&#…

臀部筋膜炎怎么治疗最有效

臀部筋膜炎的主要症状包括以下几点: 一、筋膜炎发生时会导致臀部疼痛以及局部红肿的情况。 二、可能会引起臀部活动受限。 三、可能会导致患者不能取坐位,因为坐位时可能由于局部压迫而引起筋膜炎疼痛症状加重,而引起患者不能取坐位的情况…

酷开科技丨酷开系统,带你进入惊喜不断的影视世界!

随着科技的迅速发展,智能电视已经成为家庭娱乐的重要组成部分。而要说到智能电视,就不得不提到酷开系统,作为一款智能电视操作系统,酷开系统以其独特的功能和出色的使用体验,让观众们看到了到惊喜不断的影视世界。 如…

智慧渔业捕捞计数项目设计书

(一)项目背景 根据捕捞水域的不同,我国水产捕捞可划分为海洋捕捞、远洋捕捞以及淡水捕捞三大类型。其中,淡水渔业主要是指在淡水水域进行捕捞、养殖以获得淡水水产品并对这些水产品进行加工的社会生产领域。 近年来,随…

AERMOD模型配置方法

数值模式模拟是分析大气污染物时空分布和成分贡献的重要工具,利用模拟结果可以分析大气污染的来源、成因、污染程度、持续时间、主要成分、相对贡献等问题,有助于分析并合理控制污染源排放,为产业调整提供参考。当前,针对不同理论…

Unity Meta Quest 一体机开发(五):手势抓取概述

文章目录 📕教程说明📕 Oculus Integration 中的三种手势抓取方式⭐Hand Grab⭐Touch Hand Grab⭐Distance Hand Grab 此教程相关的详细教案,文档,思维导图和工程文件会放入 Seed XR 社区。这是一个高质量知识星球 XR 社区&#…

稳定扩散与潜伏扩散:哪个更好?

在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 3D数字孪生场景编辑器 本文对这两种类型的扩散、它们的工作原理、差异和未来影响进行了详细讨论。 了解稳定扩散 通过稳定扩散生成的图像 Stable Diffu…

[数据结构大作业]HBU 河北大学校园导航

校园导航实验报告 问题描述: 以我校为例,设计一个校园导航系统,主要为来访的客人提供信息查询。系统有两类登陆账号,一类是游客,使用该系统方便校内路线查询;一类是管理员,可以使用该系统查询…

经典文献阅读之--Fast and Robust Ground Surface Estimation...(均匀B样条采样快速估计地平面)

0. 简介 对于激光雷达的地面估计分割,目前其实有很多方法做了快速并鲁棒的分割,比如说我们之前写的一篇《经典文献阅读之–FEC》一文中就给出了快速分割的方案,当中第一步就是需要对地面进行分割。而我们这次看的是一篇使用均匀B样条的方法来…

“纯真·诗心—韩玉臣油画艺术与欧洲油画珍藏展”在京开幕

11月4日,由中国艺术研究院油画院、河北省美术家协会共同主办的“纯真诗心——韩玉臣油画艺术与欧洲油画珍藏展”在中国艺术研究院油画院开幕 中国文化人物记者 苏晴/摄影报道 中国美术家协会名誉主席、中央美术学院原院长靳尚谊致辞 中国艺术研究院原院长连辑致辞 …

域名怎么注册?一步步教你如何注册自己的域名

在互联网时代,网站是个人或企业展示品牌形象和推广品牌的重要工具,而无论是个人还是企业,在建设网站时,都需要提前注册域名。那么域名应该怎么注册呢?从域名选择,到选择域名注册商,再到域名注册…

段的概念_重定位的引入

段的概念 代码段、只读数据段、可读可写数据段、BSS段。 char g_Char A; //可读可写,不能放在ROM上,应该放在RAM里 const char g_Char2 B; //只读变量,可以放在ROM上 int g_A 0; //初始值为0,没有必要浪费空间 int g_B; //没…

容器size()无符号数导致的for循环崩溃

1.问题描述 容器size()无符号数导致的for循环崩溃 for (int index 0; index < static_cast(intVec.size())-1; index) { printf(“%d”,intVec[index]); } 如果不做强转&#xff0c;可能会有两个问题&#xff1a; &#xff08;1&#xff09;编译不过 &#xff08;2&#x…

项目管理:如何利用有限的时间完成无限的任务

时间管理&#xff0c;实质上就是利用有限的时间完成无限的任务。它要求我们通过对任务的安排&#xff0c;实现在有限的时间内&#xff0c;使任务变得更有条理。 时间管理就像整理房间。如果你长期不进行整理&#xff0c;房间的杂物就会越积越多。如果将各类物品进行分类&…

Pyecharts数据可视化综合应用PyEcharts概述在线闯关_头歌实践教学平台

PyEcharts概述 第1关 快速上手任务描述相关知识导入图表类型添加数据设置图表样式输出图表链式调用编程要求测试说明代码 第1关 快速上手 任务描述 本关任务&#xff1a;快速上手使用pyEcharts进行绘图。 相关知识 为了完成本关任务&#xff0c;你需要掌握&#xff1a;1. p…

YOLOv8-Seg改进:卷积变体系列篇 | SCConv(空间和通道重建卷积) | CVPR2023

🚀🚀🚀本文改进:SCConv(空间和通道重建卷积),引入到YOLOv8,与C2f结合实现二次创新; 🚀🚀🚀SCConv亲测在多个数据集能够实现涨点 🚀🚀🚀YOLOv8-seg创新专栏:http://t.csdnimg.cn/KLSdv 学姐带你学习YOLOv8,从入门到创新,轻轻松松搞定科研; 1)手把…

PGVector 管理工具 pgAdmin

PGVector 管理工具 pgAdmin pgAdmin 下载地址pgAdmin 安装pgAdmin 使用 pgAdmin 下载地址 https://www.postgresql.org/ftp/pgadmin/pgadmin4/ pgAdmin 安装 双击 pgadmin4-*-x64.exe 安装文件&#xff0c;选择安装路径&#xff0c;后面安装提示单击 next 就可以了。 pgAdm…

虹科分享 | 一文带你了解增强现实(AR)技术的前世今生!

AR技术的前世今生 引言&#xff1a;增强现实&#xff08;Augmented Reality, AR&#xff09;技术在近几年大放光彩&#xff0c;您可能在《头号玩家》或《黑镜》等影视作品中看到过人们对AR技术的其奇思妙想&#xff0c;也可能从科普文章中了解过“元宇宙”、“数字孪生”等概念…

如何实现可视化大屏——基于VChart

引言 在大屏产品中&#xff0c;可视化扮演着信息展示和传达、用户体验和互动、数据分析和决策支持、品牌展示和差异化、故事叙述和信息呈现等至关重要的角色。作为可视化图表的重要载体之一&#xff0c;大屏与智能BI产品不管是在产品设计&#xff0c;还是可视化设计的侧重点都…