1 Star 0 Fork 20

好多包谷/RobustVideoMattingGUI

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gui.py 7.84 KB
一键复制 编辑 原始数据 按行查看 历史
天涯 提交于 2023-10-06 10:12 . modified: RVM/gui_runrvm.py
'''
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/haoduobaogu/RobustVideoMatting.git
git@gitee.com:haoduobaogu/RobustVideoMatting.git
haoduobaogu
RobustVideoMatting
RobustVideoMattingGUI
RVMGUI.SCTOOL

搜索帮助