代码拉取完成,页面将自动刷新
同步操作将从 天涯/RobustVideoMattingGUI 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
'''
Author: yuanming
Date: 2022-12-26 20:21:41
LastEditors: YuanMing
LastEditTime: 2023-09-29 18:47:00
Description:
FilePath: \RobustVideoMatting\gui.py
'''
# GUI部分的版权协议按照GPL V3,版权所属为天涯1986,希望使用此GUI代码的可以遵守GPL V3协议,保持开源的理念和初心。
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
import sys
sys.path.append(r"./RVM") # 为python便携式环境提供支持,增加当前目录作为模块索引环境
sys.path.append(r"./")
import time
from io import BytesIO
from copy import deepcopy
import configparser
# import qdarkstyle
from PyQt6 import QtCore, QtGui
from PyQt6.QtCore import QObject, Qt, QThread, pyqtSignal
from PyQt6.QtGui import QColor,QPixmap,QGuiApplication,QFontDatabase,QFont,QScreen
from PyQt6.QtWidgets import (QApplication, QButtonGroup, QColorDialog,
QFileDialog, QFrame, QHBoxLayout, QLabel,
QLineEdit, QMessageBox, QPushButton, QRadioButton, QCheckBox,
QTextBrowser, QVBoxLayout, QWidget)
from PIL import Image,ImageQt
from torch import cuda, load
from RVM.inference import convert_video
from RVM.model import MattingNetwork
from RVM.globalenv import version
import RVM.gui_train as gui_train
import RVM.gui_runrvm as gui_runrvm
import RVM.gui_capture as gui_capture
import roop.core as roopcore
from buzz.buzz import main as buzzmain
# from qt_material import apply_stylesheet
import qdarktheme
import sctoolglobal
#GUI主程序类
class mainWindow(QWidget):
#初始化函数
def __init__(self):
global debug_no_thread
super().__init__()
self.initUI()
pass
def center(self):
scaleRate = self.screen().logicalDotsPerInch()/96
qr = self.frameGeometry() #得到一个指定主窗口几何形状的矩形
qr.setWidth(round(qr.width()*scaleRate))
qr.setHeight(round(qr.height()*scaleRate))
cp = self.screen().availableGeometry().center() #计算出显示器的分辨率,通过分辨率得出中心点
qr.moveCenter(cp) #设置为屏幕的中心,矩形大小不变
self.move(qr.topLeft()) #将应用程序的左上角移动到矩形的左上角,使屏幕在窗口正中
pass
def on_RVM_run_Gui_auto_Btn_clicked(self):
self.RVMrunGUIDialg=gui_runrvm.RVMrunGUI(parent=self,auto=True)
# self.RVMrunGUIDialg.show()
pass
def on_RVM_run_Gui_Btn_clicked(self):
self.RVMrunGUIDialg=gui_runrvm.RVMrunGUI(parent=self)
self.RVMrunGUIDialg.show()
pass
def on_RVM_train_Gui_Btn_clicked(self):
self.RVMtrainGUIDialg=gui_train.RVMtrainGui(parent=self)
self.RVMtrainGUIDialg.show()
pass
def on_RVM_capture_Gui_Btn_clicked(self):
self.RVMcaptureGUIDialg=gui_capture.RVMcaptureGui(parent=self)
# self.RVMcaptureGUIDialg.show()
pass
def on_ROOP_Gui_Btn_clicked(self):
roopcore.run()
pass
def on_Buzz_Gui_Btn_clicked(self):
buzzmain()
pass
def initUI(self):
global version
self.resize(500, 200)
self.center()
#self.move(300, 300)
self.setWindowTitle('影视二次创作 & RVM GUI启动界面'+version+' by 天涯1986')
self.show()
self.setWindowIcon(QtGui.QIcon("./RVM/user.svg"))
self.mainlayout = QVBoxLayout(self)
self.RVM_run_auto_GuiBtnHBox=QHBoxLayout(self)
self.RVM_run_auto_GuiBtn = QPushButton('自动RVM抠像') #Run button, clicks are handled internally.
self.RVM_run_auto_GuiBtn.clicked.connect(self.on_RVM_run_Gui_auto_Btn_clicked) #Signal/slot mechanism
self.RVM_run_auto_GuiBtn.setMinimumHeight(40)
self.RVM_run_auto_GuiBtn.setMaximumWidth(200)
self.RVM_run_auto_GuiBtnHBox.addWidget(self.RVM_run_auto_GuiBtn,Qt.AlignmentFlag.AlignCenter) #Attachment of the button to the layout.
self.mainlayout.addLayout(self.RVM_run_auto_GuiBtnHBox) #Attachment of the button to the layout.
self.RVM_run_GuiBtnHBox=QHBoxLayout(self)
self.RVM_run_GuiBtn = QPushButton('启动RVM抠像界面') #Run button, clicks are handled internally.
self.RVM_run_GuiBtn.clicked.connect(self.on_RVM_run_Gui_Btn_clicked) #Signal/slot mechanism
self.RVM_run_GuiBtn.setMinimumHeight(40)
self.RVM_run_GuiBtn.setMaximumWidth(200)
self.RVM_run_GuiBtnHBox.addWidget(self.RVM_run_GuiBtn,Qt.AlignmentFlag.AlignCenter) #Attachment of the button to the layout.
self.mainlayout.addLayout(self.RVM_run_GuiBtnHBox) #Attachment of the button to the layout.
self.RVM_capture_GuiBtnHBox=QHBoxLayout(self)
self.RVM_capture_GuiBtn = QPushButton('启动RVM摄像头界面') #Run button, clicks are handled internally.
self.RVM_capture_GuiBtn.clicked.connect(self.on_RVM_capture_Gui_Btn_clicked)
self.RVM_capture_GuiBtn.setMinimumHeight(40)
self.RVM_capture_GuiBtn.setMaximumWidth(200)
self.RVM_capture_GuiBtnHBox.addWidget(self.RVM_capture_GuiBtn,Qt.AlignmentFlag.AlignCenter) #Attachment of the button to the layout.
self.mainlayout.addLayout(self.RVM_capture_GuiBtnHBox) #Attachment of the button to the layout.
self.RVM_train_GuiBtnHBox=QHBoxLayout(self)
self.RVM_train_GuiBtn = QPushButton('启动RVM训练界面') #Run button, clicks are handled internally.
self.RVM_train_GuiBtn.clicked.connect(self.on_RVM_train_Gui_Btn_clicked)
self.RVM_train_GuiBtn.setMinimumHeight(40)
self.RVM_train_GuiBtn.setMaximumWidth(200)
self.RVM_train_GuiBtnHBox.addWidget(self.RVM_train_GuiBtn,Qt.AlignmentFlag.AlignCenter) #Attachment of the button to the layout.
self.mainlayout.addLayout(self.RVM_train_GuiBtnHBox) #Attachment of the button to the layout.
self.ROOP_GuiBtnHBox=QHBoxLayout(self)
self.ROOP_GuiBtn = QPushButton('启动ROOP工具界面') #Run button, clicks are handled internally.
self.ROOP_GuiBtn.clicked.connect(self.on_ROOP_Gui_Btn_clicked)
self.ROOP_GuiBtn.setMinimumHeight(40)
self.ROOP_GuiBtn.setMaximumWidth(200)
self.ROOP_GuiBtnHBox.addWidget(self.ROOP_GuiBtn,Qt.AlignmentFlag.AlignCenter) #Attachment of the button to the layout.
self.mainlayout.addLayout(self.ROOP_GuiBtnHBox) #Attachment of the button to the layout.
self.Buzz_GuiBtnHBox=QHBoxLayout(self)
self.Buzz_GuiBtn = QPushButton('启动Buzz工具界面') #Run button, clicks are handled internally.
self.Buzz_GuiBtn.clicked.connect(self.on_Buzz_Gui_Btn_clicked)
self.Buzz_GuiBtn.setMinimumHeight(40)
self.Buzz_GuiBtn.setMaximumWidth(200)
self.Buzz_GuiBtnHBox.addWidget(self.Buzz_GuiBtn,Qt.AlignmentFlag.AlignCenter) #Attachment of the button to the layout.
self.mainlayout.addLayout(self.Buzz_GuiBtnHBox) #Attachment of the button to the layout.
#self.mainlayout.addLayout(self.operationBtnlayout)
# 添加主框架至界面
self.setLayout(self.mainlayout)
pass
def run():
# 创建QApplication实例
app = QApplication(sys.argv)
# 设置主题
# apply_stylesheet(app,theme='dark_cyan.xml')
# app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
qdarktheme.setup_theme("light")
# fontDb = QFontDatabase()
fontpath=sctoolglobal.resolve_relative_path('./Dependencies/fonts/oppo_Sans.ttf')
fontID = QFontDatabase.addApplicationFont(fontpath) # 此处的路径为qrc文件中的字体路径
fontFamilies = QFontDatabase.applicationFontFamilies(fontID)
print(fontFamilies) # ['LXGW WenKai']
app.setFont(QFont('OPPOSans M'))
# 创建主窗口
w = mainWindow()
# 监听窗口关闭事件
sys.exit(app.exec())
pass
if __name__ == '__main__':
run()
pass
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。