Compare commits

...

No commits in common. "DemTrain" and "649196d624da0e4a13ac6cf54656fa0eef188a1a" have entirely different histories.

20 changed files with 802 additions and 1117 deletions

View File

@ -1,425 +0,0 @@
#include "DEM_GeneVec.h"
#include<windows.h>
#include<stdio.h>
#include<stdlib.h>
#include <QSettings>
TrainMoudle::TrainMoudle()
{
//ui.setupUi(this);
}
TrainMoudle::~TrainMoudle()
{
}
QString TrainMoudle::PannelName()
{
return QString::fromLocal8Bit("");
}
QString TrainMoudle::CategoryName()
{
return QString::fromLocal8Bit("DEM模块");
}
QString TrainMoudle::EnglishName()
{
return QString::fromLocal8Bit("DEM_Module");
}
QString TrainMoudle::ChineseName()
{
return QString::fromLocal8Bit("模型构建");
}
QString TrainMoudle::Information()
{
return QString::fromLocal8Bit("模型构建");
}
QString TrainMoudle::IconPath()
{
return ":/DEM_GeneVec/resources/dem_vec.svg";
}
QWidget* TrainMoudle::CenterWidget()
{
QString gdal_path = qApp->applicationDirPath().toLocal8Bit() + "/share/gdal";
QString pro_lib_path = qApp->applicationDirPath().toLocal8Bit() + "/share/proj";
qputenv("GDAL_DATA", gdal_path.toLocal8Bit());
qputenv("PROJ_LIB", pro_lib_path.toLocal8Bit());
bool showWin = false;
if (myWidget == nullptr)
{
myWidget = new QDialog();
showWin = true;
qDebug() << "new QDialog()";
}
else
{
qDebug() << "already have myWidget";
myWidget->activateWindow();
myWidget->raise();
return myWidget;
}
ui.setupUi(myWidget);
myWidget->setWindowTitle(QString::fromLocal8Bit("模型构建"));
myWidget->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
myWidget->setWindowIcon(QIcon(":/DEM_GeneVec/resources/dem_vec.svg"));
myWidget->setAttribute(Qt::WA_QuitOnClose, false);
myWidget->setAttribute(Qt::WA_DeleteOnClose);
connect(myWidget, &QDialog::destroyed, this, [=] {
qDebug() << "----DEM train window close----";
QDir pluginsDir = QDir(qApp->applicationDirPath());
if (pluginsDir.cd("srsplugins\\DemModel"))
{
QString strConfigPath = pluginsDir.absoluteFilePath("dem_config.ini");
QFile f(strConfigPath);
if (f.exists())
{
WriteConfigPaths(strConfigPath);
f.close();
}
}
if (mThread != nullptr)
{
mThread->requestInterruption();//请求线程中断
mThread->quit();
mThread->wait();//调用wait后先调用finished信号对应的槽函数执行完成后再往下走
mWorkObject->on_cancel();
mThread = nullptr;//m_objThread, &QThread::finished, m_objThread, &QObject::deleteLater不需要delete
mWorkObject = nullptr;//m_objThread, &QThread::finished, m_obj, &QObject::deleteLater
}
myWidget->close();
myWidget = nullptr;
});
connect(ui.pbtInModel, &QPushButton::pressed, this, &TrainMoudle::choseInModel);
connect(ui.pbtInDom, &QPushButton::pressed, this, &TrainMoudle::choseInDom);
connect(ui.pbtInDsm, &QPushButton::pressed, this, &TrainMoudle::choseInDsm);
connect(ui.pbtInLabel, &QPushButton::pressed, this, &TrainMoudle::choseInLabel);
connect(ui.pbtOutModel, &QPushButton::pressed, this, &TrainMoudle::choseOutModel);
connect(ui.pushButton_ok, &QPushButton::pressed, this, &TrainMoudle::readAndStart);
connect(ui.pushButton_cancel, &QPushButton::pressed, this, &TrainMoudle::pbCancel);
connect(ui.checkBoxMid, &QCheckBox::clicked, this, [=](bool checked) {
executeMid = checked;
if (!executeMid && !executeTrain)
ui.pushButton_ok->setEnabled(false);
else
ui.pushButton_ok->setEnabled(true);
});
connect(ui.checkBoxTrain, &QCheckBox::clicked, this, [=](bool checked) {
executeTrain = checked;
if (!executeMid && !executeTrain)
ui.pushButton_ok->setEnabled(false);
else
ui.pushButton_ok->setEnabled(true);
});
ui.progressBar->setTextVisible(true);
ui.progressBar->setRange(0, 100);
ui.lineEpoch1->setValidator(new QIntValidator(0, 999, this));
ui.lineEpoch2->setValidator(new QIntValidator(0, 999, this));
ui.lineEpoch1->setText("100");
ui.lineEpoch2->setText("100");
ui.pbtInModel->setFocus();
QFile qssFile(":/DEM_GeneVec/DEM_GeneVec.qss");
qssFile.open(QFile::ReadOnly); //以只读方式打开
if (qssFile.isOpen())
{
QString qss = QLatin1String(qssFile.readAll());
myWidget->setStyleSheet(qss);
qssFile.close();
}
else
qDebug() << "无法打开文件";
QDir pluginsDir = QDir(qApp->applicationDirPath());
if (pluginsDir.cd("srsplugins\\DemModel"))
{
QString strConfigPath = pluginsDir.absoluteFilePath("dem_config.ini");
QFile f(strConfigPath);
if (f.exists())
{
ReadConfigHistoryPaths(strConfigPath);
f.close();
}
}
if (showWin)
myWidget->show();
return myWidget;
}
void TrainMoudle::startWorkThread()
{
if (mWorkObject != nullptr)
{
return;
}
mThread = new QThread();
mWorkObject = new WorkThreadObject();
mWorkObject->moveToThread(mThread);
connect(mThread, &QThread::finished, mThread, &QObject::deleteLater);
connect(mThread, &QThread::finished, mWorkObject, &QObject::deleteLater);
connect(mWorkObject, &WorkThreadObject::process, myWidget, [=](double val) {ui.progressBar->SetDoubleFormatValue(QString::fromLocal8Bit("进度"), val); });
connect(mWorkObject, &WorkThreadObject::addDataToMap, this, &TrainMoudle::addMap);
//connect(this, &TrainMoudle::killChildThread, mWorkObject, &WorkThreadObject::on_cancel);
connect(this, &TrainMoudle::start, mWorkObject, &WorkThreadObject::runTrainWork);
mThread->start();
}
//pbtDataset
//pbtValName
//pbtOutModel
void TrainMoudle::choseInModel()
{
QString inModel = QFileDialog::getOpenFileName(ui.pbtInModel, QString::fromLocal8Bit("选择输入模型文件路径"), "", "*.pth");
if (inModel != "")
ui.lineInModel->setText(inModel);
}
void TrainMoudle::choseInDom()
{
QString dataset = QFileDialog::getExistingDirectory(ui.pbtInDom, QString::fromLocal8Bit("选择输入DOM文件路径"), "");
if (dataset != "")
ui.lineInDom->setText(dataset);
}
void TrainMoudle::choseInDsm()
{
QString valName = QFileDialog::getExistingDirectory(ui.pbtInDsm, QString::fromLocal8Bit("选择输入Slope文件路径"), "");
if (valName != "")
ui.lineInDsm->setText(valName);
}
void TrainMoudle::choseInLabel()
{
QString valName = QFileDialog::getExistingDirectory(ui.pbtInLabel, QString::fromLocal8Bit("选择输入Label文件路径"), "");
if (valName != "")
ui.lineInLabel->setText(valName);
}
void TrainMoudle::choseOutModel()
{
QString outModel = QFileDialog::getExistingDirectory(ui.pbtOutModel, QString::fromLocal8Bit("选择输出模型文件路径"), "");
if (outModel != "")
ui.lineOutModel->setText(outModel);
}
void TrainMoudle::ReadConfigHistoryPaths(QString strPath)
{
QSettings configIni(strPath, QSettings::IniFormat);
//打开标题为:[DemTrain] 的组并读取出port字段的值
configIni.beginGroup("DemTrain");
ui.lineInModel->setText(configIni.value("RetrainModel").toString());
ui.lineInDom->setText(configIni.value("SrcDom").toString());
ui.lineInDsm->setText(configIni.value("SrcDsm").toString());
ui.lineInLabel->setText(configIni.value("SrcLabel").toString());
ui.lineOutModel->setText(configIni.value("TrainResult").toString());
configIni.endGroup();//关闭组
}
void TrainMoudle::WriteConfigPaths(QString strPath)
{
QSettings configIni(strPath, QSettings::IniFormat);
configIni.setIniCodec("utf-8");
//打开标题为:[DemTrain] 的组
configIni.beginGroup("DemTrain");
//更新输入模型路径
QString temp = ui.lineInModel->text();
if (temp != "")
configIni.setValue("RetrainModel", temp);
//更新输入DOM路径
temp = ui.lineInDom->text();
if (temp != "")
configIni.setValue("SrcDom", temp);
//更新输入DSM路径
temp = ui.lineInDsm->text();
if (temp != "")
configIni.setValue("SrcDsm", temp);
//更新输入Label路径
temp = ui.lineInLabel->text();
if (temp != "")
configIni.setValue("SrcLabel", temp);
//更新输出结果路径
temp = ui.lineOutModel->text();
if (temp != "")
configIni.setValue("TrainResult", temp);
configIni.endGroup();//关闭组
}
void TrainMoudle::addMap()
{
QMessageBox mess(QMessageBox::NoIcon,
QString::fromLocal8Bit("运行结束"),
QString::fromLocal8Bit("结果文件生成路径\n") + ui.lineOutModel->text(),
QMessageBox::Ok, NULL);
mess.setWindowFlags(Qt::Drawer);
mess.setButtonText(QMessageBox::Ok, QString::fromLocal8Bit("确认"));
int result = mess.exec();
//switch (result)
//{
//case QMessageBox::Ok:
// //string_list.append(ui.lineEdit_outras->text());
// //string_list.append(ui.lineEdit_outshp->text());
// //qDebug() << "----Yes:" << string_list;
// //openResultData(string_list);
// //emit addDataToCanvas(string_list);
// break;
//default:
// break;
//}
pbCancel();
}
void TrainMoudle::readAndStart()
{
QString inModel = ui.lineInModel->text();
QString inDOM = ui.lineInDom->text();
QString inDSM = ui.lineInDsm->text();
QString inLabel = ui.lineInLabel->text();
QString outModel = ui.lineOutModel->text();
ui.progressBar->SetDoubleFormatValue(QString::fromLocal8Bit("进度"), 0);
if (inModel == "" || inDOM == "" || inDSM == "" || inLabel == "" || outModel == "")
{
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("请检查输入输出文件夹或数据"));
mess.setWindowFlags(Qt::Drawer);
int result = mess.exec();
return;
}
QDir inDOMdir(inDOM);
if (!inDOMdir.exists())
{
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("DOM文件夹不存在"));
mess.setWindowFlags(Qt::Drawer);
int result = mess.exec();
return;
}
QDir inDSMdir(inDSM);
if (!inDSMdir.exists())
{
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("Slope文件夹不存在"));
mess.setWindowFlags(Qt::Drawer);
int result = mess.exec();
return;
}
QDir inLabeldir(inLabel);
if (!inLabeldir.exists())
{
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("Label文件夹不存在"));
mess.setWindowFlags(Qt::Drawer);
int result = mess.exec();
return;
}
QDir outModeldir(outModel);
if (!outModeldir.exists())
{
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("模型输出文件夹不存在"));
mess.setWindowFlags(Qt::Drawer);
int result = mess.exec();
return;
}
if (executeMid && executeTrain)
qDebug() << "executeMid & executeTrain";
if (executeMid && (!executeTrain))
qDebug() << "executeMid, not executeTrain";
if ((!executeMid) && executeTrain)
{
//判断train文件夹下有无训练集文件夹
QDir dirImage(outModel + "/Images");
QDir dirLabel(outModel + "/Labels");
if (!dirImage.exists() || !dirLabel.exists())
{
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"),
QString::fromLocal8Bit("未找到训练集文件夹\n确保Images和Labels在以下路径中: \n") + outModel);
mess.setWindowFlags(Qt::Drawer);
int result = mess.exec();
return;
}
//判断文件是否匹配
QStringList imgList = getAllFiles(outModel + "/Images", "tif");
QStringList labelList = getAllFiles(outModel + "/Labels", "tif");
if (imgList.size() == 0 || labelList.size() == 0)
{
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"),
QString::fromLocal8Bit("训练集文件夹内为空"));
mess.setWindowFlags(Qt::Drawer);
int result = mess.exec();
return;
}
if (imgList.size() != labelList.size())
{
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"),
QString::fromLocal8Bit("训练集Images、Labels文件夹内文件不匹配"));
mess.setWindowFlags(Qt::Drawer);
int result = mess.exec();
return;
}
}
if (ui.lineEpoch1->text() == "" || ui.lineEpoch2->text() == "")
{
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("请输入正确的训练轮数"));
mess.setWindowFlags(Qt::Drawer);
int result = mess.exec();
return;
}
QString epoch1 = ui.lineEpoch1->text();
QString epoch2 = ui.lineEpoch2->text();
if (mThread == nullptr)
{
qDebug() << "--startThread";
startWorkThread();
}
emit start(inModel, inDOM, inDSM, inLabel, outModel, executeMid, executeTrain, epoch1, epoch2);
}
QStringList TrainMoudle::getAllFiles(QString path, QString fileType)
{
QDir dir(path);
if (!dir.exists())
return QStringList();
dir.setFilter(QDir::Files | QDir::NoSymLinks);
QFileInfoList list = dir.entryInfoList();
int file_count = list.count();
if (file_count <= 0)
return QStringList();
QStringList files;
for (int i = 0; i < file_count; i++)
{
QFileInfo file_info = list.at(i);
QString suffix = file_info.suffix();
if (QString::compare(suffix, QString(fileType), Qt::CaseInsensitive) == 0)
{
QString absolute_file_path = file_info.absoluteFilePath();
files.append(absolute_file_path);
}
}
return files;
}
void TrainMoudle::pbCancel()
{
delete myWidget;//调起&QDialog::destroyed
}

View File

@ -1,79 +0,0 @@
#pragma once
#include <QtWidgets/QDialog>
#include <QFileDialog>
#include <QMetaType>
#include <QDialog>
#include <QDebug>
#include <QObject>
#include <QMessageBox>
#include <QPushButton>
#include <QString>
#include <QThread>
#include <QVector>
#include <QIntValidator>
#include "ui_DEM_GeneVec.h"
#include "ThreadObject.h"
#include "SrsMainPluginInterFace.h"
#include "gdal_priv.h"
//#include "gdal_alg_priv.h"
class TrainMoudle : public SrsMainInterface
{
Q_OBJECT
Q_INTERFACES(SrsMainInterface)
Q_PLUGIN_METADATA(IID MainInterface_iid)
public:
TrainMoudle();
~TrainMoudle();
virtual QString PannelName() override;
virtual QString CategoryName() override;
virtual QString EnglishName() override;
virtual QString ChineseName() override;
virtual QString Information() override;
virtual QString IconPath() override;
virtual QWidget* CenterWidget() override;
void startWorkThread();
//读json文件获取历史存储的路径
void ReadConfigHistoryPaths(QString strPath);
//保存本次打开的路径到json文件
void WriteConfigPaths(QString strPath);
QStringList getAllFiles(QString path, QString fileType);
public slots:
void choseInModel();
void choseInDom();
void choseInDsm();
void choseInLabel();
void choseOutModel();
void addMap();
//pushbutton_OK
void readAndStart();
void pbCancel();
signals:
void start(QString inModel, QString dom, QString dsm, QString label, QString outModel, bool mid, bool train, QString epoch1, QString epoch2);
void killChildThread();
private:
Ui::DEM_GeneVecClass ui;
QDialog* myWidget = nullptr;
WorkThreadObject* mWorkObject = nullptr;
QThread* mThread = nullptr;
bool executeMid = true;
bool executeTrain = true;
};

View File

@ -1,6 +0,0 @@
<RCC>
<qresource prefix="/DEM_GeneVec">
<file>resources/dem_vec.svg</file>
<file>DEM_GeneVec.qss</file>
</qresource>
</RCC>

View File

@ -1,98 +0,0 @@
QProgressBar#progressBar {
border:0px solid white;
text-align:center;
color:black;
}
QProgressBar#progressBar:chunk {
background-color:#3FABBA;
width:20px;
}
QProgressBar#progressBar QLineEdit {
border:none;
color:black;
padding-left:5px;
font-size:16px;
background-color:transparent;
}
QLabel{
color:black;
font-family:'Microsoft YaHei';
font-size:12px;
}
/*----QPushButtonÑùʽ±í*/
#pushButton_ok, #pushButton_cancel, #pbtInModel, #pbtInDom, #pbtInDsm, #pbtInLabel, #pbtOutModel{
font-family:'Microsoft YaHei';
font-size:12px;
background-color: #ffffff;
border: 1px solid #dcdfe6;
padding: 2px;
border-radius: 5px;
max-height:20px;
}
#pushButton_ok, #pushButton_cancel{
min-width:36px;
}
#pushButton_ok:hover, #pushButton_cancel:hover, #pbtInModel:hover, #pbtInDom:hover, #pbtInDsm:hover,#pbtInLabel:hover,#pbtOutModel:hover{
background-color: #ecf5ff;
color: #409eff;
}
#pushButton_ok:pressed, #pushButton_cancel:pressed, #pbtInModel:pressed, #pbtInDom:pressed, #pbtInDsm:pressed,#pbtInLabel:pressed,#pbtOutModel:pressed{
border: 1px solid #3a8ee6;
color: #409eff;
}
#pushButton_ok:checked, #pushButton_cancel:checked, #pbtInModel:checked, #pbtInDom:checked, #pbtInDsm:checked,#pbtInLabel:checked,#pbtOutModel:checked{
border: 1px solid #3a8ee6;
color: #409eff;
}
#pushButton_ok:focus, #pushButton_cancel:focus, #pbtInModel:focus, #pbtInDom:focus, #pbtInDsm:focus,#pbtInLabel:focus,#pbtOutModel:focus{
border: 1px solid #3a8ee6;
color: #409eff;
outline: none;
}
/*----QLineEditÑùʽ*/
#lineInModel, #lineInDsm, #lineInDom, #lineOutModel, #lineInLabel, #lineEpoch1, #lineEpoch2{
border:0px;
border-bottom: 1px solid #B3B3B3;
font-family:'Microsoft YaHei';
font-size:12px;
background-color:transparent;
}
#lineInModel:hover, #lineInDsm:hover, #lineInDom:hover, #lineOutModel:hover, #lineInLabel:hover, #lineEpoch1:hover, #lineEpoch2:hover{
border-bottom: 2px solid #66A3FF;
}
#lineInModel:focus, #lineInDsm:focus, #lineInDom:focus, #lineOutModel:focus, #lineInLabel:focus, #lineEpoch1:focus, #lineEpoch2:focus{
border-bottom: 2px solid #7666FF;
}
/*QCheckBox{
background:transparent;
border:0px;
color:black;
min-height: 20px;
min-width: 60px;
}
QCheckBox::disabled{
background:transparent;
border:0px;
color:#202020;
min-height: 20px;
min-width: 60px;
}
QCheckBox::indicator{
margin-right:-10px;
}
QCheckBox::indicator:checked{
image: url(:/RemoteSensingProcess/Resources/checkbox_checked.svg);
width:25px;
}
QCheckBox::indicator:unchecked{
image: url(:/RemoteSensingProcess/Resources/checkbox_unchecked.svg);
width:25px;
}
QCheckBox::indicator:disabled{
image: url(:/RemoteSensingProcess/Resources/checkbox_disabled.svg);
width:25px;
}*/

View File

@ -1,97 +0,0 @@
#include <QProcess>
#include <QDir>
#include <QApplication>
#include <QDebug>
#include <QTimer>
#include <windows.h>
#include "DEM_GeneVec.h"
#include "ThreadObject.h"
using namespace std;
WorkThreadObject::WorkThreadObject(QObject* parent) :QObject(parent)
{
qRegisterMetaType<std::function<void(double)> >("std::function<void(double)>");
}
WorkThreadObject::~WorkThreadObject()
{
}
void WorkThreadObject::runTrainWork(QString inModel, QString dom, QString dsm, QString label, QString outModel, bool mid, bool train, QString epoch1, QString epoch2)
{
QString str = QString("%1->%2,thread id:%3").arg(__FILE__).arg(__FUNCTION__).arg((int)QThread::currentThreadId());
qDebug() << str;
QDir pluginsDir = QDir(qApp->applicationDirPath());
if (!pluginsDir.cd("models\\envs"))
{
qDebug() << "no folder models\\envs";
return;
}
QString exeDirName = pluginsDir.absoluteFilePath("train_4c_vegetaion.exe");
QString inDom = " --dom_path "+ dom + "/";
QString inDsm = " --dsm_path " + dsm + "/";
QString inLabel = " --label_path " + label + "/";
QString trainedModel = " --retrained_model " + inModel;
QString save_model = " --save_model " + outModel + "/";
QString strMid, strTrain;
if (mid)
strMid = " --exe_mid True ";
else
strMid = " --exe_mid False ";
if (train)
strTrain = " --exe_train True";
else
strTrain = " --exe_train False";
QString strEpoch1, strEpoch2;
strEpoch1 = " --epoch1 " + epoch1;
strEpoch2 = " --epoch2 " + epoch2;
//QString CUDA = " --CUDA False";
QString ss = exeDirName + inDom + inDsm + inLabel + trainedModel + save_model+ strMid + strTrain + strEpoch1 + strEpoch2;// + CUDA
qDebug() << ss;
QProcess* pProces = new QProcess(this);
connect(pProces, SIGNAL(readyReadStandardOutput()), this, SLOT(on_read()));
pProces->start(ss);
}
void WorkThreadObject::on_read()
{
mProces = (QProcess*)sender();
QString output = QString::fromLocal8Bit(mProces->readAllStandardOutput());
//qDebug() << "out:" << output;
if (output.toDouble() > 0)
{
qDebug() << "exe out:" << output.toDouble();
emit process(output.toDouble());
if (output.toDouble() == 100.0)
{
emit addDataToMap();
}
}
else
qDebug() << "Unresolved exe out:" << output;
}
void WorkThreadObject::on_cancel()
{
QString str = QString("--1.%1->%2,thread id:%3").arg(__FILE__).arg(__FUNCTION__).arg((int)QThread::currentThreadId());
qDebug() << str;
if (mProces == nullptr)
{
qDebug() << "--mProces null";
}
else
{
QString KillStr = "taskkill /f /im train_4c_vegetaion.exe";
mProces->startDetached(KillStr);
qDebug() << "--kill Proces";
}
}

View File

@ -1,48 +0,0 @@
#ifndef THREADOBJECT_H
#define THREADOBJECT_H
#include <functional>
#include <QMessageBox>
#include <QObject>
#include <QProcess>
#include <QThread>
#include <QVector>
#include <iostream>
//#include "MultiQProcess.h"
//#include "qtclasslibrary1_global.h"
#include "SrsMainPluginInterFace.h"
#include "ui_DEM_GeneVec.h"
//#include "Extract.h"
using namespace std;
class TrainMoudle;
class WorkThreadObject :public QObject
{
Q_OBJECT
public:
WorkThreadObject(QObject* parent = NULL);
~WorkThreadObject();
void on_cancel();
signals:
void process(double value);
void addDataToMap();
public slots:
//void RunWork(QString landsat_file, QString gf_file, QString tvdi_file);
//void RunWork(QString file1, QString file2, QString file_out, std::function<void(int)>progressCallback);
//void RunWork(QString file1, QString file2, QString file_out);
void runTrainWork(QString inModel, QString dom, QString dsm, QString label, QString outModel, bool mid, bool train, QString epoch1, QString epoch2);
void on_read();
private:
QProcess* mProces = nullptr;
};
#endif

View File

@ -1,16 +0,0 @@
#include "DEM_GeneVec.h"
#include <QtWidgets/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QString gdal_path = qApp->applicationDirPath().toLocal8Bit() + "/share/gdal";
QString pro_lib_path = qApp->applicationDirPath().toLocal8Bit() + "/share/proj";
qputenv("GDAL_DATA", gdal_path.toLocal8Bit());
qputenv("PROJ_LIB", pro_lib_path.toLocal8Bit());
TrainMoudle w;
w.CenterWidget()->show();
return a.exec();
}

View File

@ -1,23 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31911.196
VisualStudioVersion = 16.0.32630.194
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DEM_GeneVec", "DEM_GeneVec\DEM_GeneVec.vcxproj", "{858826AD-BC7C-4B9D-8E48-626392904948}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LandslideTrain", "LandslideTrain\LandslideTrain.vcxproj", "{1D23BAC7-1D1A-48BE-9796-93F34E435A5A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{858826AD-BC7C-4B9D-8E48-626392904948}.Release|x64.ActiveCfg = Release|x64
{858826AD-BC7C-4B9D-8E48-626392904948}.Release|x64.Build.0 = Release|x64
{1D23BAC7-1D1A-48BE-9796-93F34E435A5A}.Release|x64.ActiveCfg = Release|x64
{1D23BAC7-1D1A-48BE-9796-93F34E435A5A}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Qt5Version = qt5.14.2
SolutionGuid = {B8F00221-FFCF-43EE-B1EC-68EEC3E5BC58}
SolutionGuid = {9DAFCFF4-8408-40F6-A160-95047A99BB28}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,455 @@
#include "LandslideTrain.h"
#include <QSettings>
LandslideTrain::LandslideTrain()
{
//ui.setupUi(this);
}
QString LandslideTrain::PannelName()
{
return QString::fromLocal8Bit("地质模块");
}
QString LandslideTrain::CategoryName()
{
return QString::fromLocal8Bit("地质模块");
}
QString LandslideTrain::EnglishName()
{
return QString::fromLocal8Bit("LandslideTrain");
}
QString LandslideTrain::ChineseName()
{
return QString::fromLocal8Bit("模型构建");
}
QString LandslideTrain::Information()
{
return QString::fromLocal8Bit("模型构建");
}
QString LandslideTrain::IconPath()
{
return ":/LandslideTrain/resources/dem_vec.svg";
}
QWidget* LandslideTrain::CenterWidget()
{
//QString gdal_path = qApp->applicationDirPath().toLocal8Bit() + "/share/gdal";
//QString pro_lib_path = qApp->applicationDirPath().toLocal8Bit() + "/share/proj";
//qputenv("GDAL_DATA", gdal_path.toLocal8Bit());
//qputenv("PROJ_LIB", pro_lib_path.toLocal8Bit());
bool showWin = false;
if (myWidget == nullptr)
{
myWidget = new QDialog();
showWin = true;
qDebug() << "new QDialog()";
}
else
{
qDebug() << "already have myWidget";
//激活窗口并提升至顶层
myWidget->activateWindow();
myWidget->raise();
return myWidget;
}
ui.setupUi(myWidget);
myWidget->setWindowTitle(QString::fromLocal8Bit("模型训练"));
myWidget->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
myWidget->setWindowIcon(QIcon(":/LandslideTrain/resources/dem_vec.svg"));
myWidget->setAttribute(Qt::WA_QuitOnClose, false);
myWidget->setAttribute(Qt::WA_DeleteOnClose);
connect(myWidget, &QDialog::destroyed, this, [=] {
qDebug() << "----Landslide train window close----";
QDir pluginsDir = QDir(qApp->applicationDirPath());
if (pluginsDir.cd("srsplugins\\SldModel"))
{
QString strConfigPath = pluginsDir.absoluteFilePath("sld_config.ini");
QFile f(strConfigPath);
if (f.exists())
{
WriteConfigPaths(strConfigPath);
f.close();
}
}
if (mWorkThread != nullptr)
{
mWorkThread->requestInterruption();
mWorkThread->quit();
mWorkThread->wait();//调用wait后先调用finished信号对应的槽函数执行完成后再往下走
mWorkObject->on_cancel();
mWorkThread = nullptr;//mWorkThread, &QThread::finished, mWorkThread, &QObject::deleteLater不需要delete
mWorkObject = nullptr;//mWorkThread, &QThread::finished, mWorker, &QObject::deleteLater
}
myWidget->close();
myWidget = nullptr;
});
connect(ui.pbtInModel, &QPushButton::clicked, this, &LandslideTrain::chooseInModel);
connect(ui.pbtInDataset, &QPushButton::clicked, this, &LandslideTrain::chooseInDataset);
connect(ui.pbtInLabel, &QPushButton::clicked, this, &LandslideTrain::chooseInLabel);
connect(ui.pbtOutResult, &QPushButton::clicked, this, &LandslideTrain::chooseResultPath);
connect(ui.pushButton_ok, &QPushButton::clicked, this, &LandslideTrain::readAndStart);
connect(ui.pushButton_cancel, &QPushButton::clicked, this, &LandslideTrain::pbCancel);
ui.lineEpoch1->setValidator(new QIntValidator(0, 999, this));
ui.lineEpoch2->setValidator(new QIntValidator(0, 999, this));
ui.lineEpoch1->setText("100");
ui.lineEpoch2->setText("100");
ui.pbtInModel->setFocus();
connect(ui.checkBoxGenData, &QCheckBox::clicked, this, [=](bool checked) {
executeGenData = checked;
if (!executeGenData && !executeTrain)
ui.pushButton_ok->setEnabled(false);
else
ui.pushButton_ok->setEnabled(true);
});
connect(ui.checkBoxTrain, &QCheckBox::clicked, this, [=](bool checked) {
executeTrain = checked;
if (!executeGenData && !executeTrain)
ui.pushButton_ok->setEnabled(false);
else
ui.pushButton_ok->setEnabled(true);
});
ui.progressBar->setTextVisible(true);
ui.progressBar->setRange(0, 100);
QFile qssFile(":/LandslideTrain/LandslideTrain.qss");
qssFile.open(QFile::ReadOnly); //以只读方式打开
if (qssFile.isOpen())
{
QString qss = QLatin1String(qssFile.readAll());
myWidget->setStyleSheet(qss);
qssFile.close();
}
else
qDebug() << "-- no qssFile";
QDir pluginsDir = QDir(qApp->applicationDirPath());
if (pluginsDir.cd("srsplugins\\SldModel"))
{
QString strConfigPath = pluginsDir.absoluteFilePath("sld_config.ini");
QFile f(strConfigPath);
if (f.exists())
{
ReadConfigHistoryPaths(strConfigPath);
f.close();
}
}
if (showWin)
myWidget->show();
return myWidget;
}
void LandslideTrain::startWorkThread()
{
if (mWorkObject != nullptr)
{
return;
}
mWorkThread = new QThread();
mWorkObject = new WorkObject();
mWorkObject->moveToThread(mWorkThread);
connect(mWorkThread, &QThread::finished, mWorkThread, &QObject::deleteLater);
connect(mWorkThread, &QThread::finished, mWorkObject, &QObject::deleteLater);
connect(mWorkObject, &WorkObject::progress, myWidget, [=](double val) {ui.progressBar->SetDoubleFormatValue(QString::fromLocal8Bit("进度"), val); });
connect(mWorkObject, &WorkObject::trainFinished, this, &LandslideTrain::finished);
connect(this, &LandslideTrain::start, mWorkObject, &WorkObject::runTrainWork);
mWorkThread->start();
}
void LandslideTrain::ReadConfigHistoryPaths(QString strPath)
{
QSettings configIni(strPath, QSettings::IniFormat);
//打开标题为:[SldTrain] 的组并读取出port字段的值
configIni.beginGroup("SldTrain");
ui.lineInModel->setText(configIni.value("RetrainModel").toString());
ui.lineInDataset->setText(configIni.value("SrcDom").toString());
ui.lineInLabel->setText(configIni.value("SrcLabel").toString());
ui.lineOutResult->setText(configIni.value("TrainResult").toString());
configIni.endGroup();//关闭组
}
void LandslideTrain::WriteConfigPaths(QString strPath)
{
QSettings configIni(strPath, QSettings::IniFormat);
configIni.setIniCodec("utf-8");
//打开标题为:[SldTrain] 的组
configIni.beginGroup("SldTrain");
//更新输入模型路径
QString temp = ui.lineInModel->text();
if (temp != "")
configIni.setValue("RetrainModel", temp);
//更新输入DOM路径
temp = ui.lineInDataset->text();
if (temp != "")
configIni.setValue("SrcDom", temp);
//更新输入Label路径
temp = ui.lineInLabel->text();
if (temp != "")
configIni.setValue("SrcLabel", temp);
//更新输出结果路径
temp = ui.lineOutResult->text();
if (temp != "")
configIni.setValue("TrainResult", temp);
configIni.endGroup();//关闭组
}
void LandslideTrain::readAndStart()
{
QString inDataset = ui.lineInDataset->text();
QString inLabel=ui.lineInLabel->text();
QString inModel=ui.lineInModel->text();
QString outResult=ui.lineOutResult->text();
if (inDataset == "" || inLabel == "" || inModel == "" || outResult == "")
{
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("请检查输入输出路径"));
mess.setWindowFlags(Qt::Drawer);
int result = mess.exec();
return;
}
ui.progressBar->SetDoubleFormatValue(QString::fromLocal8Bit("进度"), 0);
QDir inDatasetDir(inDataset);
if (!inDatasetDir.exists())
{
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("训练数据文件夹不存在"));
mess.setWindowFlags(Qt::Drawer);
int result = mess.exec();
return;
}
QDir inLabelDir(inLabel);
if (!inLabelDir.exists())
{
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("标签数据文件夹不存在"));
mess.setWindowFlags(Qt::Drawer);
int result = mess.exec();
return;
}
QDir outModelDir(outResult);
if (!outModelDir.exists())
{
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("模型输出文件夹不存在"));
mess.setWindowFlags(Qt::Drawer);
int result = mess.exec();
return;
}
if (executeGenData && executeTrain)
qDebug() << "executeGenData & executeTrain";
if (executeGenData && (!executeTrain))
qDebug() << "executeGenData, not executeTrain";
if ((!executeGenData) && executeTrain)
{
//判断train文件夹下有无训练集文件夹
QDir dirImage(outResult + "/Images");
QDir dirLabel(outResult + "/Labels");
if (!dirImage.exists() || !dirLabel.exists())
{
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"),
QString::fromLocal8Bit("未找到训练集文件夹\n确保Images和Labels在以下路径中: \n") + outResult);
mess.setWindowFlags(Qt::Drawer);
int result = mess.exec();
return;
}
//判断文件是否匹配
QStringList imgList = getAllFiles(outResult + "/Images", "tif");
QStringList labelList = getAllFiles(outResult + "/Labels", "tif");
if (imgList.size() == 0 || labelList.size() == 0)
{
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"),
QString::fromLocal8Bit("训练集文件夹内为空"));
mess.setWindowFlags(Qt::Drawer);
int result = mess.exec();
return;
}
if (imgList.size() != labelList.size())
{
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"),
QString::fromLocal8Bit("训练集Images、Labels文件夹内文件不匹配"));
mess.setWindowFlags(Qt::Drawer);
int result = mess.exec();
return;
}
}
if (ui.lineEpoch1->text() == "" || ui.lineEpoch2->text() == "")
{
QMessageBox mess(QMessageBox::NoIcon, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("请输入正确的训练轮数"));
mess.setWindowFlags(Qt::Drawer);
int result = mess.exec();
return;
}
QString epoch1 = ui.lineEpoch1->text();
QString epoch2 = ui.lineEpoch2->text();
if (mWorkThread == nullptr)
{
qDebug() << "--startThread";
startWorkThread();
}
emit start(inModel, inDataset, inLabel, outResult, executeGenData, executeTrain, epoch1, epoch2);
}
QStringList LandslideTrain::getAllFiles(QString path, QString fileType)
{
QDir dir(path);
if (!dir.exists())
return QStringList();
dir.setFilter(QDir::Files | QDir::NoSymLinks);
QFileInfoList list = dir.entryInfoList();
int file_count = list.count();
if (file_count <= 0)
return QStringList();
QStringList files;
for (int i = 0; i < file_count; i++)
{
QFileInfo file_info = list.at(i);
QString suffix = file_info.suffix();
if (QString::compare(suffix, QString(fileType), Qt::CaseInsensitive) == 0)
{
QString absolute_file_path = file_info.absoluteFilePath();
files.append(absolute_file_path);
}
}
return files;
}
void LandslideTrain::finished()
{
QMessageBox mess(QMessageBox::NoIcon,
QString::fromLocal8Bit("运行结束"),
QString::fromLocal8Bit("结果文件生成路径\n") + ui.lineOutResult->text(),
QMessageBox::Ok, NULL);
mess.setWindowFlags(Qt::Drawer);
mess.setButtonText(QMessageBox::Ok, QString::fromLocal8Bit("确认"));
int result = mess.exec();
pbCancel();
}
void LandslideTrain::pbCancel()
{
//qDebug() << "--pbtCancel";
delete myWidget;//调起&QDialog::destroyed
}
void LandslideTrain::chooseInModel()
{
QString dirModel = QFileDialog::getOpenFileName(ui.pbtInModel, QString::fromLocal8Bit("选择输入初始训练模型文件"), "", "*.pth");
if (dirModel != "")
ui.lineInModel->setText(dirModel);
}
void LandslideTrain::chooseInDataset()
{
QString dirDataset = QFileDialog::getExistingDirectory(ui.pbtInDataset, QString::fromLocal8Bit("选择输入训练数据路径"), "");
if (dirDataset != "")
ui.lineInDataset->setText(dirDataset);
}
void LandslideTrain::chooseInLabel()
{
QString dirLabel = QFileDialog::getExistingDirectory(ui.pbtInLabel, QString::fromLocal8Bit("选择输入标签数据路径"), "");
if (dirLabel != "")
ui.lineInLabel->setText(dirLabel);
}
void LandslideTrain::chooseResultPath()
{
QString dirResult = QFileDialog::getExistingDirectory(ui.pbtOutResult, QString::fromLocal8Bit("选择输出模型文件路径"), "");
if (dirResult != "")
ui.lineOutResult->setText(dirResult);
}
void WorkObject::runTrainWork(QString inModel, QString dataset, QString label, QString outModel, bool gen, bool train, QString epoch1, QString epoch2)
{
QDir pluginsDir = QDir(qApp->applicationDirPath());
if (!pluginsDir.cd("models\\envs"))
{
qDebug() << "no folder models\\envs";
return;
}
QString exeDirName = pluginsDir.absoluteFilePath("train_3c_landslide.exe");
QString inDom = " --dom_path " + dataset + "/";
QString inLabel = " --label_path " + label + "/";
QString trainedModel = " --retrained_model " + inModel;
QString save_model = " --save_model " + outModel + "/";
QString strMid, strTrain;
if (gen)
strMid = " --exe_mid True ";
else
strMid = " --exe_mid False ";
if (train)
strTrain = " --exe_train True";
else
strTrain = " --exe_train False";
QString strEpoch1, strEpoch2;
strEpoch1 = " --epoch1 " + epoch1;
strEpoch2 = " --epoch2 " + epoch2;
QString ss = exeDirName + inDom + inLabel + trainedModel + save_model + strMid + strTrain + strEpoch1 + strEpoch2;
qDebug() << ss;
QProcess* pProces = new QProcess(this);
connect(pProces, SIGNAL(readyReadStandardOutput()), this, SLOT(on_read()));
pProces->start(ss);
}
void WorkObject::on_read()
{
mProcess = (QProcess*)sender();
QString output = QString::fromLocal8Bit(mProcess->readAllStandardOutput());
if (output.toDouble() > 0)
{
qDebug() << "exe out:" << output.toDouble();
emit progress(output.toDouble());
if (output.toDouble() == 100.0)
{
delete mProcess;
mProcess = nullptr;
emit trainFinished();
}
}
else
qDebug() << "Unresolved exe out:" << output;
}
void WorkObject::on_cancel()
{
if (mProcess == nullptr)
{
qDebug() << "--mProcess null";
}
else
{
QString KillStr = "taskkill /f /im train_3c_landslide.exe";
mProcess->startDetached(KillStr);
qDebug() << "--kill Process";
}
}

View File

@ -0,0 +1,96 @@
#pragma once
#include <QtWidgets/QDialog>
#include "ui_LandslideTrain.h"
#include <QProcess>
#include <QThread>
#include <QFile>
#include <QIcon>
#include <QDebug>
#include <QMessageBox>
#include <QFileDialog>
#include <QStringList>
#include <QIntValidator>
#include "SrsMainPluginInterFace.h"
#include <string>
#include <iostream>
using namespace std;
class WorkObject :public QObject
{
Q_OBJECT
public:
void on_cancel();
public slots:
void runTrainWork(QString inModel, QString inDataset, QString label, QString outModel, bool gen, bool train, QString epoch1, QString epoch2);
void on_read();
signals:
void progress(double value);
void trainFinished();
private:
QProcess* mProcess = nullptr;
};
class LandslideTrain : public SrsMainInterface
{
Q_OBJECT
Q_INTERFACES(SrsMainInterface)
Q_PLUGIN_METADATA(IID MainInterface_iid)
public:
LandslideTrain();
virtual QString PannelName() override;
virtual QString CategoryName() override;
virtual QString EnglishName() override;
virtual QString ChineseName() override;
virtual QString Information() override;
virtual QString IconPath() override;
virtual QWidget* CenterWidget() override;
void startWorkThread();
QStringList getAllFiles(QString path, QString fileType);
//读json文件获取历史存储的路径
void ReadConfigHistoryPaths(QString strPath);
//保存本次打开的路径到json文件
void WriteConfigPaths(QString strPath);
public slots:
void readAndStart();
void pbCancel();
void chooseInModel();
void chooseInDataset();
void chooseInLabel();
void chooseResultPath();
void finished();
signals:
void start(QString inModel, QString inDataset, QString label, QString outModel, bool gen, bool train, QString epoch1, QString epoch2);
private:
Ui::LandslideTrainClass ui;
QDialog* myWidget = nullptr;
QThread* mWorkThread = nullptr;
WorkObject* mWorkObject = nullptr;
bool executeGenData = true;
bool executeTrain = true;
};

View File

@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/LandslideTrain">
<file>resources/dem_vec.svg</file>
<file>LandslideTrain.qss</file>
</qresource>
</RCC>

View File

@ -0,0 +1,68 @@
QProgressBar#progressBar {
border:0px solid white;
text-align:center;
color:black;
}
QProgressBar#progressBar:chunk {
background-color:#3FABBA;
width:20px;
}
QProgressBar#progressBar QLineEdit {
border:none;
color:black;
padding-left:5px;
font-size:16px;
background-color:transparent;
}
QLabel{
color:black;
font-family:'Microsoft YaHei';
font-size:12px;
}
/*----QPushButtonÑùʽ±í*/
#pushButton_ok, #pushButton_cancel, #pbtInModel, #pbtInDataset, #pbtInDsm, #pbtInLabel, #pbtOutResult{
font-family:'Microsoft YaHei';
font-size:12px;
background-color: #ffffff;
border: 1px solid #dcdfe6;
padding: 2px;
border-radius: 5px;
max-height:20px;
}
#pushButton_ok, #pushButton_cancel{
min-width:36px;
}
#pushButton_ok:hover, #pushButton_cancel:hover, #pbtInModel:hover, #pbtInDataset:hover, #pbtInLabel:hover,#pbtOutResult:hover{
background-color: #ecf5ff;
color: #409eff;
}
#pushButton_ok:pressed, #pushButton_cancel:pressed, #pbtInModel:pressed, #pbtInDataset:pressed, #pbtInLabel:pressed,#pbtOutResult:pressed{
border: 1px solid #3a8ee6;
color: #409eff;
}
#pushButton_ok:checked, #pushButton_cancel:checked, #pbtInModel:checked, #pbtInDataset:checked, #pbtInLabel:checked,#pbtOutResult:checked{
border: 1px solid #3a8ee6;
color: #409eff;
}
#pushButton_ok:focus, #pushButton_cancel:focus, #pbtInModel:focus, #pbtInDataset:focus, #pbtInLabel:focus,#pbtOutResult:focus{
border: 1px solid #3a8ee6;
color: #409eff;
outline: none;
}
/*----QLineEditÑùʽ*/
#lineInModel, #lineInDataset, #lineOutResult, #lineInLabel, #lineEpoch1, #lineEpoch2{
border:0px;
border-bottom: 1px solid #B3B3B3;
font-family:'Microsoft YaHei';
font-size:12px;
background-color:transparent;
}
#lineInModel:hover, #lineInDataset:hover, #lineOutResult:hover, #lineInLabel:hover, #lineEpoch1:hover, #lineEpoch2:hover{
border-bottom: 2px solid #66A3FF;
}
#lineInModel:focus, #lineInDataset:focus, #lineOutResult:focus, #lineInLabel:focus, #lineEpoch1:focus, #lineEpoch2:focus{
border-bottom: 2px solid #7666FF;
}

View File

@ -1,158 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DEM_GeneVecClass</class>
<widget class="QDialog" name="DEM_GeneVecClass">
<class>LandslideTrainClass</class>
<widget class="QDialog" name="LandslideTrainClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>550</width>
<height>320</height>
<width>500</width>
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>550</width>
<height>320</height>
<width>500</width>
<height>300</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>550</width>
<height>320</height>
<width>500</width>
<height>300</height>
</size>
</property>
<property name="windowTitle">
<string/>
<string>LandslideTrain</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QLineEdit" name="lineInDom">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QLineEdit" name="lineEpoch1">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>解冻训练次数</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEpoch2">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineOutModel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pbtInModel">
<property name="text">
<string>选择文件</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineInLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QPushButton" name="pbtOutModel">
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>75</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>选择文件夹</string>
</property>
</widget>
<widget class="QLineEdit" name="lineOutResult"/>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineInModel"/>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineInDsm">
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>输入训练数据路径</string>
</property>
</widget>
</item>
<item row="3" column="2">
<item row="1" column="1">
<widget class="QLineEdit" name="lineInDataset"/>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pbtInLabel">
<property name="minimumSize">
<size>
@ -167,68 +65,12 @@
</size>
</property>
<property name="text">
<string>选择文件夹</string>
<string>打开文件夹</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>输入DOM文件路径</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>输入DSM文件路径</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pbtInDom">
<item row="0" column="2">
<widget class="QPushButton" name="pbtInModel">
<property name="minimumSize">
<size>
<width>75</width>
@ -242,115 +84,126 @@
</size>
</property>
<property name="text">
<string>选择文件夹</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_mask">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>输入Label文件路径</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pbtInDsm">
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>75</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>选择文件夹</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_mask_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>输出模型文件路径</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
<string>打开文件</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>输入初始模型文件路径</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
<string>输入初始训练模型路径</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_4">
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>输入标签数据路径</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>输出模型文件路径</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pbtInDataset">
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<width>75</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>打开文件夹</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineInLabel"/>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="pbtOutResult">
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>75</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>打开文件夹</string>
</property>
</widget>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="lineEpoch1">
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>解冻训练次数</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEpoch2">
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>冻结训练次数</string>
</property>
@ -363,17 +216,11 @@
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>100</number>
<number>40</number>
</property>
<item>
<widget class="QCheckBox" name="checkBoxMid">
<widget class="QCheckBox" name="checkBoxGenData">
<property name="text">
<string>生成训练集、验证集</string>
</property>
@ -407,14 +254,8 @@
</item>
<item>
<widget class="QPushButton" name="pushButton_ok">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>确</string>
<string>确认</string>
</property>
</widget>
</item>
@ -444,15 +285,11 @@
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="CProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
<widget class="CProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
@ -467,19 +304,21 @@
<tabstops>
<tabstop>lineInModel</tabstop>
<tabstop>pbtInModel</tabstop>
<tabstop>lineInDom</tabstop>
<tabstop>pbtInDom</tabstop>
<tabstop>lineInDsm</tabstop>
<tabstop>pbtInDsm</tabstop>
<tabstop>lineInDataset</tabstop>
<tabstop>pbtInDataset</tabstop>
<tabstop>lineInLabel</tabstop>
<tabstop>pbtInLabel</tabstop>
<tabstop>lineOutModel</tabstop>
<tabstop>pbtOutModel</tabstop>
<tabstop>lineOutResult</tabstop>
<tabstop>pbtOutResult</tabstop>
<tabstop>lineEpoch1</tabstop>
<tabstop>lineEpoch2</tabstop>
<tabstop>checkBoxGenData</tabstop>
<tabstop>checkBoxTrain</tabstop>
<tabstop>pushButton_ok</tabstop>
<tabstop>pushButton_cancel</tabstop>
</tabstops>
<resources>
<include location="DEM_GeneVec.qrc"/>
<include location="LandslideTrain.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -7,11 +7,10 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{858826AD-BC7C-4B9D-8E48-626392904948}</ProjectGuid>
<ProjectGuid>{1D23BAC7-1D1A-48BE-9796-93F34E435A5A}</ProjectGuid>
<Keyword>QtVS_v304</Keyword>
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0.19041.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0</WindowsTargetPlatformVersion>
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
<ProjectName>DEM_Train</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
@ -40,13 +39,8 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<IncludePath>D:\qgis\osgeo4w\include;D:\qgis\osgeo4w\apps\Qt5\include;$(IncludePath)</IncludePath>
<LibraryPath>D:\qgis\osgeo4w\lib;D:\qgis\osgeo4w\apps\Qt5\lib;$(LibraryPath)</LibraryPath>
<TargetName>dem1-$(ProjectName)</TargetName>
<TargetName>landslide1_train</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Link>
<AdditionalDependencies>gdal_i.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
<ClCompile>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
@ -61,24 +55,22 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<QtRcc Include="LandslideTrain.qrc" />
<QtUic Include="LandslideTrain.ui" />
<QtMoc Include="LandslideTrain.h" />
<ClCompile Include="CProgressBar.cpp" />
<ClCompile Include="ThreadObject.cpp" />
<QtRcc Include="DEM_GeneVec.qrc" />
<QtMoc Include="DEM_GeneVec.h" />
<ClCompile Include="DEM_GeneVec.cpp" />
<ClCompile Include="LandslideTrain.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<QtUic Include="DEM_GeneVec.ui" />
</ItemGroup>
<ItemGroup>
<QtMoc Include="ThreadObject.h" />
<QtMoc Include="SrsMainPluginInterFace.h" />
<QtMoc Include="CProgressBar.h" />
<ClInclude Include="x64\Release\uic\ui_DEM_GeneVec.h" />
</ItemGroup>
<ItemGroup>
<None Include="DEM_GeneVec.qss" />
<QtMoc Include="CProgressBar.h" />
<ClInclude Include="x64\Release\uic\ui_LandslideTrain.h" />
</ItemGroup>
<ItemGroup>
<None Include="LandslideTrain.qss" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">

View File

@ -3,7 +3,7 @@
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
<Extensions>qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
@ -21,18 +21,18 @@
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
<Extensions>ts</Extensions>
</Filter>
<Filter Include="process">
<UniqueIdentifier>{96222dac-cebd-43e4-bfdd-ebee13ab43e3}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<QtRcc Include="DEM_GeneVec.qrc">
<QtRcc Include="LandslideTrain.qrc">
<Filter>Resource Files</Filter>
</QtRcc>
<QtMoc Include="DEM_GeneVec.h">
<QtUic Include="LandslideTrain.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtMoc Include="LandslideTrain.h">
<Filter>Header Files</Filter>
</QtMoc>
<ClCompile Include="DEM_GeneVec.cpp">
<ClCompile Include="LandslideTrain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
@ -40,27 +40,11 @@
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ThreadObject.cpp">
<Filter>process</Filter>
</ClCompile>
<ClCompile Include="CProgressBar.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtUic Include="DEM_GeneVec.ui">
<Filter>Form Files</Filter>
</QtUic>
</ItemGroup>
<ItemGroup>
<ClInclude Include="x64\Release\uic\ui_DEM_GeneVec.h">
<Filter>Form Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<QtMoc Include="ThreadObject.h">
<Filter>process</Filter>
</QtMoc>
<QtMoc Include="SrsMainPluginInterFace.h">
<Filter>Header Files</Filter>
</QtMoc>
@ -69,7 +53,12 @@
</QtMoc>
</ItemGroup>
<ItemGroup>
<None Include="DEM_GeneVec.qss">
<ClInclude Include="x64\Release\uic\ui_LandslideTrain.h">
<Filter>Form Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="LandslideTrain.qss">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>

10
LandslideTrain/main.cpp Normal file
View File

@ -0,0 +1,10 @@
#include "LandslideTrain.h"
#include <QtWidgets/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
LandslideTrain w;
w.CenterWidget()->show();
return a.exec();
}

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB