• 大小: 14KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-18
  • 语言: 其他
  • 标签: pyqt5  keras  GUI  

资源简介

一个集深度学习训练过程与缺陷检测过程为一体的界面,但是中间遇到许多问题,其中解决耗时最长的问题就是如何将深度学习训练过程实时显示在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


评论

共有 条评论