介绍
github地址:https://github.com/sczhou/CodeFormer
[NeurIPS 2022] Towards Robust Blind Face Restoration with Codebook Lookup Transformer
效果:
?
测试环境:
anconda3+python3.8
torch==1.9.0+cu111
pyqt5
部分代码:
import math
import threading
import time
import cv2
import os
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QImage, QPixmap
from PyQt5.QtWidgets import QLabel, QFileDialog
from CodeformerManager import *
class MainForm(QtWidgets.QMainWindow):
def setupUi(self):
self.setObjectName("Form")
self.resize(1320, 703)
self.cb_background_enhance = QtWidgets.QCheckBox(self)
self.cb_background_enhance.setGeometry(QtCore.QRect(20, 30, 91, 19))
self.cb_background_enhance.setObjectName("cb_background_enhance")
self.cb_background_enhance.clicked.connect(self.cb_background_enhance_clicked)
self.cb_face_upsampling = QtWidgets.QCheckBox(self)
self.cb_face_upsampling.setGeometry(QtCore.QRect(140, 30, 111, 19))
self.cb_face_upsampling.setObjectName("cb_face_upsampling")
self.cb_face_upsampling.clicked.connect(self.cb_face_upsampling_cliecked)
self.label = QtWidgets.QLabel(self)
self.label.setGeometry(QtCore.QRect(260, 32, 72, 15))
self.label.setObjectName("label")
self.sb_rescale = QtWidgets.QSpinBox(self)
self.sb_rescale.setGeometry(QtCore.QRect(350, 28, 46, 22))
self.sb_rescale.setObjectName("sb_rescale")
self.sb_rescale.setMinimum(2)
self.sb_rescale.setMaximum(4)
self.sb_rescale.setValue(2)
self.sb_rescale.valueChanged.connect(self.sb_rescale_value_changed)
self.hs_fidelity = QtWidgets.QSlider(self)
self.hs_fidelity.setGeometry(QtCore.QRect(600, 30, 311, 22))
self.hs_fidelity.setMaximum(100)
self.hs_fidelity.setProperty("value", 50)
self.hs_fidelity.setOrientation(QtCore.Qt.Horizontal)
self.hs_fidelity.setObjectName("hs_fidelity")
self.hs_fidelity.valueChanged.connect(self.hs_fidelity_changed)
self.label_2 = QtWidgets.QLabel(self)
self.label_2.setGeometry(QtCore.QRect(420, 30, 171, 16))
self.label_2.setObjectName("label_2")
self.label_3 = QtWidgets.QLabel(self)
self.label_3.setGeometry(QtCore.QRect(920, 30, 41, 20))
self.label_3.setObjectName("label_3")
self.pb_import = QtWidgets.QPushButton(self)
self.pb_import.setText("导入图片")
self.pb_import.setGeometry(QtCore.QRect(960, 28, 80, 30))
self.pb_import.setObjectName("pb_import")
self.pb_import.clicked.connect(self.import_image)
self.pb_start = QtWidgets.QPushButton(self)
self.pb_start.setText("开始修复")
self.pb_start.setGeometry(QtCore.QRect(1050, 28, 80, 30))
self.pb_start.setObjectName("pb_start")
self.pb_start.clicked.connect(self.start_restore)
self.label_src = QtWidgets.QLabel(self)
self.label_src.setGeometry(QtCore.QRect(10, 80, 631, 571))
self.label_src.setStyleSheet("background:rgb(0, 0, 0)")
self.label_src.setText("")
self.label_src.setScaledContents(True)
self.label_src.setObjectName("label_src")
self.label_dest = QtWidgets.QLabel(self)
self.label_dest.setGeometry(QtCore.QRect(650, 80, 661, 571))
self.label_dest.setStyleSheet("background:rgb(0, 0, 0)")
self.label_dest.setText("")
self.label_dest.setObjectName("label_dest")
self.label_dest.setScaledContents(True)
self.retranslateUi()
QtCore.QMetaObject.connectSlotsByName(self)
self.init_all()
?使用方法:
安装好python环境,然后执行代码
python main.py即可出现界面
下载地址: