精度评估弹出框

This commit is contained in:
董月坤 2022-11-11 10:31:31 +08:00
parent 82f6c5d3fc
commit 6306932b38
2 changed files with 92 additions and 5 deletions

View File

@ -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
@ -169,9 +169,35 @@ class EvaluationPlugin(BasicPlugin):
''')
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)
@ -184,3 +210,11 @@ class EvaluationPlugin(BasicPlugin):
t = Thread(target=self.run_alg, args=(layer, dialog.gt_file))
t.start()
from .window import Ui_Form
class Win(QWidget,Ui_Form):
def __init__(self,txt):
super().__init__()
self.setupUi(self)
self.label.setText(txt)

View File

@ -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"))