資源簡介
一個集深度學習訓練過程與缺陷檢測過程為一體的界面,但是中間遇到許多問題,其中解決耗時最長的問題就是如何將深度學習訓練過程實時顯示在GUI界面的Textbrowser上,實現(xiàn)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(‘迭代次數(shù)為?%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
評論
共有 條評論