如何处理0xC0000409在尝试使用c进行拦截时运行tensorflow重新训练时崩溃?

2024-10-01 11:20:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我的目标是为tensorflow创建一个小gui。我在DOS中的命令是

"C:\pythonpath\python.exe" "E:\retrainpath\retrain.py" --image_dir "D:\picturepath"

它应该起作用

^{pr2}$

然而,尝试截取c#中的输出不会使用

private void button1_Click(object sender, EventArgs e)
{
    ParameterizedThreadStart pts = new ParameterizedThreadStart(trainieren);
    Thread thread = new Thread(pts);
    thread.Start(@"D:\picturepath");
}

string python = @"C:\pythonpath\python.exe";
string retrain = @"E:\retrainpath\retrain.py";


void trainieren(Object bildv)
{
    this.Invoke((MethodInvoker)delegate
    {
        button1.Enabled = false;
    });
    string bildverzeichnis = (string)bildv;
    string ApplicationPath = python;
    string ApplicationArguments = "\""+retrain + "\" --image_dir \"" + bildverzeichnis+"\"";
    Console.WriteLine(ApplicationPath + " " + ApplicationArguments);
    Process ProcessObj = new Process();
    ProcessObj.StartInfo.FileName = ApplicationPath;
    ProcessObj.StartInfo.Arguments = ApplicationArguments;
    ProcessObj.StartInfo.UseShellExecute = false;
    ProcessObj.StartInfo.RedirectStandardOutput = true;
    ProcessObj.StartInfo.RedirectStandardError = true;
    ProcessObj.StartInfo.RedirectStandardInput = true;
    ProcessObj.StartInfo.CreateNoWindow = true;
    ProcessObj.ErrorDataReceived += build_ErrorDataReceived;
    ProcessObj.OutputDataReceived += build_ErrorDataReceived;

    ProcessObj.EnableRaisingEvents = true;
    ProcessObj.Start();
    ProcessObj.BeginOutputReadLine();
    ProcessObj.BeginErrorReadLine();
    ProcessObj.WaitForExit();
    this.Invoke((MethodInvoker)delegate
    {
        button1.Enabled = true;
        this.Text = "Fertig";
    });
    statusInnen("Beendet");
    pb(0, 100, 0);
}

以及

void build_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
    string zeile = e.Data;
    Console.WriteLine(zeile);
}

单击button1时所发生的一切是:button1被禁用然后被启用,调试窗口中的输出是两个空行。在

我在python的minidump中发现它崩溃是因为0xc000409,一个STATUS\u STACK\u BUFFER_溢出。在

运行替代文件

import sys

s = 'Hello, world.'
print(s)

印刷品你好,世界。在c#中,所以张量流重新训练是一个问题,但仅当从c#调用时。在


Tags: buildtruenewstringthisexepythonpathvoid