From 6306932b38a4c320c5867f8bcafedaedd37ada86 Mon Sep 17 00:00:00 2001 From: unknown <1713588126@qq.com> Date: Fri, 11 Nov 2022 10:31:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E5=BA=A6=E8=AF=84=E4=BC=B0=E5=BC=B9?= =?UTF-8?q?=E5=87=BA=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/evaluation/main.py | 44 ++++++++++++++++++++++++++---- plugins/evaluation/window.py | 53 ++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 5 deletions(-) create mode 100644 plugins/evaluation/window.py diff --git a/plugins/evaluation/main.py b/plugins/evaluation/main.py index 28acb23..85d9058 100644 --- a/plugins/evaluation/main.py +++ b/plugins/evaluation/main.py @@ -7,7 +7,7 @@ import numpy as np from rscder.gui.actions import ActionManager from rscder.plugins.basic import BasicPlugin from rscder.gui.layercombox import RasterLayerCombox,ResultLayercombox, ResultPointLayerCombox -from PyQt5.QtWidgets import QAction, QFileDialog, QDialog, QLabel, QHBoxLayout, QVBoxLayout, QPushButton,QDialogButtonBox +from PyQt5.QtWidgets import QAction, QFileDialog, QDialog, QLabel, QHBoxLayout, QVBoxLayout, QPushButton,QDialogButtonBox,QWidget from PyQt5.QtGui import QIcon from PyQt5.QtCore import Qt from osgeo import gdal @@ -168,10 +168,36 @@ class EvaluationPlugin(BasicPlugin): Kappa: {kappa(cfm)} ''') f.flush() - - os.system(f'c:/windows/notepad.exe "{result_path}"') + + txt=f''' + 预测结果:{layer.path}\n - self.send_message.emit('精度评估完成') + 真值: {gt}\n + + 混淆矩阵结果:\n + + 真实值 | 变化 | 未变化 + 预测值 + 变化 {cfm[1,1]}\t, {cfm[1,0]} + 未变化 {cfm[0,1]}\t, {cfm[0,0]} + + + 归一化混淆矩阵: + 真实值 | 变化 | 未变化 + 预测值 + 变化 {cfm[1,1]/np.sum(cfm)}\t, {cfm[1,0]/np.sum(cfm)} + 未变化 {cfm[0,1]/np.sum(cfm)}\t, {cfm[0,0]/np.sum(cfm)} + + OA: {(cfm[1,1] + cfm[0,0])/np.sum(cfm)} + F1: {cfm[1,1] / (np.sum(cfm[1,:]) + np.sum(cfm[:,1]) - cfm[1,1])} + Kappa: {kappa(cfm)} + ''' + + self.msgbox = Win(txt) + self.msgbox.show() + # os.system(f'c:/windows/notepad.exe "{result_path}"') + + # self.send_message.emit('精度评估完成') def show_dialog(self): dialog = EvalutationDialog(self.mainwindow) @@ -183,4 +209,12 @@ class EvaluationPlugin(BasicPlugin): # return t = Thread(target=self.run_alg, args=(layer, dialog.gt_file)) t.start() - \ No newline at end of file + +from .window import Ui_Form +class Win(QWidget,Ui_Form): + + def __init__(self,txt): + super().__init__() + + self.setupUi(self) + self.label.setText(txt) \ No newline at end of file diff --git a/plugins/evaluation/window.py b/plugins/evaluation/window.py new file mode 100644 index 0000000..cb1cdd6 --- /dev/null +++ b/plugins/evaluation/window.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'c:\Users\dong\Desktop\111\test\untitled.ui' +# +# Created by: PyQt5 UI code generator 5.15.7 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets + + +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(604, 513) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth()) + Form.setSizePolicy(sizePolicy) + self.horizontalLayout_3 = QtWidgets.QHBoxLayout(Form) + self.horizontalLayout_3.setObjectName("horizontalLayout_3") + self.scrollArea = QtWidgets.QScrollArea(Form) + self.scrollArea.setWidgetResizable(True) + self.scrollArea.setObjectName("scrollArea") + self.scrollAreaWidgetContents = QtWidgets.QWidget() + self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 580, 489)) + self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") + self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.scrollAreaWidgetContents) + self.horizontalLayout_4.setObjectName("horizontalLayout_4") + self.horizontalLayout_2 = QtWidgets.QHBoxLayout() + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.label = QtWidgets.QLabel(self.scrollAreaWidgetContents) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth()) + self.label.setSizePolicy(sizePolicy) + self.label.setObjectName("label") + self.horizontalLayout_2.addWidget(self.label) + self.horizontalLayout_4.addLayout(self.horizontalLayout_2) + self.scrollArea.setWidget(self.scrollAreaWidgetContents) + self.horizontalLayout_3.addWidget(self.scrollArea) + + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Form")) + self.label.setText(_translate("Form", "TextLabel"))