资源简介
一个集深度学习训练过程与缺陷检测过程为一体的界面,但是中间遇到许多问题,其中解决耗时最长的问题就是如何将深度学习训练过程实时显示在GUI界面的Textbrowser上,实现Textbrowser作为控制台输出的功能。原博客链接:https://blog.csdn.net/weixin_42532587/article/details/105689637

代码片段和文件信息
import ctypes
import win32con
import sys
from PyQt5.QtWidgets import QMainWindow QApplication QDialog QFileDialog QMessageBox
from PyQt5 import QtCore QtGui
from PyQt5.QtCore import QThread pyqtSignal
from mainwindow import Ui_MainWindow
from Model_training import Ui_Dialog
from Detection import Ui_Dialog1
import global_var as gl
from model_train import model_training
class EmittingStream(QtCore.Qobject):
textWritten = QtCore.pyqtSignal(str)
def write(self text):
self.textWritten.emit(str(text))
def flush(self): # real signature unknown; restored from __doc__
“““ flush(self) “““
pass
class MainUI(QMainWindow Ui_MainWindow):
def __init__(self):
super(MainUI self).__init__()
self.setupUi(self)
self.pushButton_Training.setstyleSheet(‘background:rgb(0 255 0)‘)
self.pushButton_Detection.setstyleSheet(‘background:rgb(0 255 0)‘)
self.pushButton_Tuichu.setstyleSheet(‘color:red‘)
self.pushButton_Tuichu.clicked.connect(self.close)
self.Exit.triggered.connect(self.close)
# self.pushButton_Detection.clicked.connect()
class Training_Dialog(QDialog Ui_Dialog):
def __init__(self):
super(Training_Dialog self).__init__()
self.setupUi(self)
self.pushButton_training.setstyleSheet(‘background:rgb(0 255 0)‘)
self.pushButton_validation.setstyleSheet(‘background:rgb(0 255 0)‘)
self.pushButton_Start.setstyleSheet(‘background:rgb(0 255 0)‘)
self.pushButton_Stop.setstyleSheet(‘background:rgb(255 0 0)‘)
self.comboBox_BS.addItems([‘2‘ ‘4‘ ‘8‘ ‘16‘ ‘32‘ ‘64‘ ‘128‘])
self.comboBox_EP.addItems([‘1‘ ‘20‘ ‘50‘ ‘100‘])
self.comboBox_LR.addItems([‘0.1‘ ‘0.01‘ ‘0.001‘ ‘0.0001‘ ‘0.00001‘])
self.radioButton_AlexNet.setChecked(True)
self.pushButton_training.clicked.connect(self.openfile)
self.pushButton_validation.clicked.connect(self.openfile1)
sys.stdout = EmittingStream(textWritten=self.normalOutputWritten)
sys.stder = EmittingStream(textWritten=self.normalOutputWritten)
self.pushButton_Start.clicked.connect(self.run_training)
self.pushButton_Stop.clicked.connect(self.stop_training)
self.my_thread = MyThread() # 实例化线程对象
def hyper_para(self):
Epoch = self.comboBox_EP.currentText()
gl.Epoch = int(Epoch)
print(‘迭代次数为 %d‘ % gl.Epoch)
batch_size = self.comboBox_BS.currentText()
gl.batch_size = int(batch_size)
print(‘批量尺寸为 %d‘ % gl.batch_size)
Learning_rate = self.comboBox_LR.currentText()
gl.learning_rate = float(Learning_rate)
print(‘学习率为 %f‘ % gl.learning_rate)
def stop_training(self):
self.my_thread.is_on = False
ret = ctypes.windll.kernel32.TerminateThread( # @UndefinedVariable
self.my_thread.handle 0)
print(‘终止训
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6457 2020-04-21 19:01 Deep_learning_GUI\ceshi.py
文件 3813 2020-04-21 22:13 Deep_learning_GUI\Detection.py
文件 3667 2020-04-21 22:13 Deep_learning_GUI\Detection.ui
文件 478 2020-04-22 10:05 Deep_learning_GUI\global_var.py
文件 3884 2020-04-16 23:00 Deep_learning_GUI\mainwindow.py
文件 3432 2020-04-16 23:00 Deep_learning_GUI\mainwindow.ui
文件 2993 2020-04-22 10:22 Deep_learning_GUI\model_prediction.py
文件 6779 2020-04-22 10:24 Deep_learning_GUI\model_train.py
文件 5151 2020-04-21 17:32 Deep_learning_GUI\Model_training.py
文件 5308 2020-04-21 17:32 Deep_learning_GUI\Model_training.ui
文件 11387 2020-04-22 16:41 Deep_learning_GUI\run.py
目录 0 2020-04-19 11:28 Deep_learning_GUI\Model_logs\train\plugins\profile
目录 0 2020-04-22 20:49 Deep_learning_GUI\Model_logs\train\plugins
目录 0 2020-04-22 20:49 Deep_learning_GUI\Model_logs\train
目录 0 2020-04-17 21:03 Deep_learning_GUI\Model_logs\validation
目录 0 2020-04-22 20:49 Deep_learning_GUI\Model
目录 0 2020-04-22 20:50 Deep_learning_GUI\Model_logs
目录 0 2020-04-22 20:49 Deep_learning_GUI
----------- --------- ---------- ----- ----
53349 18
- 上一篇:山东科技大学概率论试题
- 下一篇:数据结构课程设计-城市链表
相关资源
- the_definitive_guide_to_linux_network_programm
- ANSYS 14.5 Design Exploration User Guide
- 嵌入式图形界面MiniGUI的示例程序9例
- STM32基于rt_thread操作系统的SDHC卡文件
- GUI银行管理系统
- STM32F103RBT6驱动UC1698控制芯片的160160黑
- System Design Interview - An Insider’s Guide
- VCS lab 和 VCS lab guide
- easygui手册
- 英文原版-Certified Ethical Hacker CEH Foun
- Guide to Reliable Distributed Systems
- Channel waveguides fabrication in bulk Lithium
- ARM嵌入式系统开发:软件设计与优化
- IT6802 Programming Guide
- CWAP Certified Wireless Analysis Professional
- Academic Writing--a practical guide for studen
- Unigui 1.50.0.1481(含keygen)
- 自己做的一个简单GUI扑克纸牌识别-
- 爬取豆瓣排行榜电影数据(含GUI界面
- 基于最小错误率的贝叶斯手写数字分
- 超级免杀加壳工具GUI版
- maven权威指南中文版+maven the definitiv
- iOS Programming The Big Nerd Ranch Guide 第6版
- A Practical Guide to Support Vector Classifica
- Unity3D 实战视频教程 保卫萝卜 2D 游戏
- Unity无限滚动列表(自动分页和网络请
- Molecular identification polymorphism and asso
- 最新Proxmark3命令帮助中文版.pdf
- mfocGUI.exe软件中文版
- 字库工具 guitool(Trial) Setup 1.13.rar
评论
共有 条评论