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

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.mfbz.cn/a/143327.html

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

相关文章

ninja 编译介绍

首先献上官方链接 https://ninja-build.org/manual.html Ninja 何以存在? 从官方文档看出,编译很快!怎么实现的呢??所以,还是值得了解一下的,继续~ 编译优势 项目中使用 具体语法,…

Find My滑雪板|苹果Find My技术与滑雪板结合,智能防丢,全球定位

滑雪板运动是一项越来越受年轻人青睐的运动,随着年轻人的消费能力不断提高,滑雪板市场也会得到更多的机会和发展空间。滑雪板市场规模是一个不断增长的市场,目前市场规模已经相当大。根据统计数据显示,全球滑雪板市场规模约为26亿…

多语言外贸跨境商城源码/支持多商家入驻/一键采集铺货/后台下单等

随着全球化的不断深入,多语言外贸跨境商城已成为全球贸易的新趋势。我们致力于打造一个支持多商家入驻、一键采集铺货、后台下单等多项功能的电商平台,帮助您轻松开启全球贸易之旅。 一、多语言支持,让您的事业走向世界 我们提供多语言支持&a…

map与set使用方法总结

一,map与set简介 map与set本质上便是一个关联容器,它们的底层都是一个叫做红黑树的数据结构。当然,所谓的红黑树又是一个二叉搜索树。所以追根溯源,map和set都是用二叉搜索树(红黑树)实现的容器。 在C中&am…

【工程部署】在RK3588上部署OCR(文字检测识别)(DBNet+CRNN)

硬件平台: 1、firefly安装Ubuntu系统的RK3588; 2、安装Windows系统的电脑一台,其上安装Ubuntu18.04系统虚拟机。 参考手册:《00-Rockchip_RKNPU_User_Guide_RKNN_API_V1.3.0_CN》 《RKNN Toolkit Lite2 用户使用指南》 1、文…

【kafka】windows安装启动

1.zookeeper的安装与启动 快速打开window powershell: windowx,选 2.kafka下载 —注意kafka和zookeeper需要版本匹配 安装路径 注意,kafka安装目录不能有空格。文件下载到: D:\Program_Files\kafka_2.12-3.6.0新建logs文件 修改c…

语聚AI助力微信客服系统与企业知识库的API连接,提升电商平台用户运营效果

建立连接:语聚AI与微信客服系统的API集成 在现代电商运营中,智能客服系统已经成为一种必备的工具。而在这方面,微信客服系统因其广泛的用户基础和便捷的操作方式,成为了业界广泛采用的工具。但是,为了更好地满足用户需…

算法笔记——递归(1)

这里写目录标题 递归的思想序列求最大值翻转字符串斐波那契数列数塔回文字符串上楼汉诺塔棋盘覆盖问题数字螺旋矩阵盒分形 递归的思想 子问题须与原始问题为同样的事,且更为简单。 不能无限制地调用本身,须有个出口,化简为非递归状况处理 序…

el-table本地与线上的样式不一致出现错乱

使用el-table的时候有几个表头是循环出来的,出现在本地运行的时候,表头内el-input输入框样式正常,但是发布以后出现样式错乱问题 线上样式错乱:​ 本地正常: 出现这个问题的原因是我有几个表头是循环出来的&#xff0…

阿里云2核2G云服务器99元一年!3M带宽的ECS云服务器哦

经济型e实例2核2G3M带宽优惠价99元一年 除了轻量服务器配置,经济型e实例2核2G3M配置也成为了用户关注的焦点。这款云服务器以99元一年的价格,适合个人和普通企业用户搭建网站、开发测试等需求。 我买的是阿里云这款99元的云服务器,活动参与地…

结婚请柬H5页面制作系统源码 带完整搭建教程

在过去的几年中,移动设备的普及率越来越高,人们越来越倾向于在手机上浏览网页。因此,开发一款基于H5技术的结婚请柬制作系统,可以满足用户在移动设备上浏览请柬的需求。今天源码小编来给大家介绍一款结婚请柬H5页面制作的源码系统…

开发技术-批量设置redis过期时间

1. 背景 项目组使用 Redis 太过奔放,许多 key 并没有设置过期时间,导致 Redis 服务器内存压力过大,需要成批次的为 key 设置过期时间。 2. 方法 import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.st…

将按键放到输入框内:

如何将将Button放到输入框内&#xff1f; 效果图&#xff1a; 步骤如下&#xff1a; button 外围用template 包裹一层 <template #suffix v-if"row.WorkerRole TPM"> <el-inputtype"text"v-model"row.JobNumber"placeholder"…

2023年最新前端面试题汇总大全(含答案超详细,HTML,JS,CSS汇总篇)-- 持续更新

专项练习–持续更新 HTML篇CSS篇JS篇Vue篇TypeScript篇React篇微信小程序篇前端面试题汇总大全二&#xff08;含答案超详细&#xff0c;Vue&#xff0c;TypeScript&#xff0c;React&#xff0c;微信小程序&#xff0c;Webpack 汇总篇&#xff09;-- 持续更新 前端面试题汇总大…

平价护眼台灯推荐,好用且性价比高的护眼台灯推荐

想要选好护眼台灯首先我们要知道什么是护眼台灯&#xff0c;大的方向来看&#xff0c;护眼台灯就是可以保护视力的台灯&#xff0c;深入些讲就是具备让灯发出接近自然光特性的光线&#xff0c;同时光线不会伤害人眼而出现造成眼部不适甚至是视力降低的照明设备。 从细节上看就…

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

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

酒店数据抓取

好的&#xff0c;以下是使用Haskell编写的一个简单的网页爬虫程序&#xff0c;用于抓取Booking.com和云地接酒店数据的示例。这个程序使用HTTP代理&#xff0c;代理信息为proxy_host: jshk.com.cn。 import Network.HTTP import Network.HTTP代理 import Network.URImain :: I…

CSS实现图片滑动对比

实现效果图如下&#xff1a; css代码&#xff1a; 知识点&#xff1a;resize: horizontal; 文档地址 <style>.image-slider {position: relative;display: inline-block;width: 500px;height: 300px;}.image-slider>div {position: absolute;top: 0;bottom: 0;left: …

学开发语言 求职互联网行业的未来发展

我喜欢回答各种各样的问题&#xff0c;自然也喜欢记录下自己的一些观点和看法。希望给朋友们多一点参考&#xff0c;也欢迎交流探讨。 提问&#xff1a; 自考本科&#xff0c;学的开发语言&#xff0c;问互联网行业求职和发展&#xff01; 作为一个资深码农&#xff0c;对这样…

Animate 2024 for mac动画制作软件

Animate 2024是一款由Adobe公司开发的强大动画制作软件&#xff0c;它能帮助用户轻松制作出各种精美的动画作品。Animate 2024拥有强大而直观的设计工作流程&#xff0c;能够让用户自由地构建动画场景、绘制精美的图形&#xff0c;并轻松添加动态效果。无论是传统手绘风格还是骨…
最新文章