我正在尝试从QTDesigner应用程序运行python脚本。
我在QT应用程序中拥有c ++代码
void RPlatform::handleButtonClicked(){
QString TrainFolder = ui->trainfolder->text();
QString TrainSize = ui->trainsize->text();
QString TestSize = ui->testsize->text();
QString TrainBatchSize = ui->trainbatchsize->text();
QString TestBatchSize = ui->testbatchsize->text();
QString OptType=ui->optimization->currentText();
QString NumClasses=ui->numclasses->text();
QString Blr=ui->blr->text();
QString Gamma=ui->gamma->text();
QString WH=ui->wh->text();
QString Bid=ui->backgroundID->text();
QString SelectedModels="";
if(ui->regnetCB->isChecked())
SelectedModels = "RegNet";
else if(ui->resnetCB->isChecked())
SelectedModels = "ResNet";
else if(ui->inceptionnetCB->isChecked())
SelectedModels = "InceptionNet";
else if(ui->regnetCB->isChecked() && ui->resnetCB->isChecked())
SelectedModels = "RegNetResNet";
else if(ui->regnetCB->isChecked() && ui->inceptionnetCB->isChecked())
SelectedModels = "RegNetInceptionNet";
else if(ui->resnetCB->isChecked() && ui->inceptionnetCB->isChecked())
SelectedModels = "ResNetInceptionNet";
else if(ui->regnetCB->isChecked() && ui->resnetCB->isChecked() && ui->inceptionnetCB->isChecked())
SelectedModels = "RegNetResNetInceptionNet";
QStringList arguments=QStringList() << "/home/Softwares/Projects/caffe-ssd-2/Prototxtfiles/NumberPlate/NetworkArchitecture/GUI.py" << SelectedModels << TrainFolder << TrainSize << TestSize << TrainBatchSize << TestBatchSize << OptType << NumClasses << Blr << Gamma << WH << Bid;
//QString path="/home/Softwares/Projects/caffe-ssd-2/Prototxtfiles/NumberPlate/NetworkArchitecture";
QProcess *myprocess=new QProcess(this);
myprocess->start("python",arguments);
myprocess->waitForFinished();
myprocess->close();
}
我的Python代码如下。
class GUIMain:
def __init__(self, Models,TrainFolder, TrainSize, TestSize, BatchSize, TestbatchSize, Optimization, NumClasses, BaseLr, gamma, W_H, backID):
self.ModelSelection=Models
self.imageSize=[W_H,W_H,3]
self.train_data='TrainFolder/'+'lmdb/NumberPlate_trainval_lmdb'
self.test_data='TrainFolder/'+'lmdb/NumberPlate_test_lmdb'
self.label_map_file='TrainFolder/'+'labelmap_NumberPlate.prototxt'
self.name_size_file = 'TrainFolder/'+'test_name_size.txt'
self.pretrain_model=''
self.numClasses=NumClasses
self.num_test_image=TestSize
self.num_total_train_images=TrainSize
self.test_batch_size=TestbatchSize
self.base_lr=BaseLr
self.gamma=self.gamma
self.batch_size_per_device=BatchSize
self.background_label_id=backID
self.opt_type=Optimization
print("path "+TrainFolder)
if __name__ == '__main__':
GUIMain(Models,TrainFolder, TrainSize, TestSize, BatchSize, TestbatchSize, Optimization, NumClasses, BaseLr, gamma, W_H, backID)
我的python脚本本身可以运行。 但是,当我从Qt运行时,在Ubuntu中使用TOP命令检查的进程列表中没有运行任何应用程序。
在这种情况下如何查看python脚本的打印内容?
如何检查python是否成功运行?