我试图在linux上使用tensorflow lib在c#中启动一个训练过程,该过程将在tensorflow源代码文件夹中执行python脚本“object_detection / legacy / train.py” .

我的流程设置:

var workingDir = "/models/research/object-detection";
Directory.SetCurrentDirectory(workingDir);
var process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName = "python",
                    Arguments = $@"legacy/train.py --logtostderr --train_dir={trainDir} --pipeline_config_path={configPath}",
                    CreateNoWindow = true,
                    UseShellExecute = false,
                    RedirectStandardOutput = true,
                    RedirectStandardError = true
                },
                EnableRaisingEvents = true
            };

我使用Directory.SetCurrentDirectory()设置了当前的工作目录,但是当我开始处理时,总是得到错误:

ImportError: cannot import name input_reader_pb2

我试着运行: protoc object_detection/protos/*.proto --python_out=. ,它成功没有错误,但是当启动进程仍然得到 importError .

但是如果我转到“/ models / research / object-detection”并在终端中运行命令:

python legacy/train.py ...

有用 .

这是我的日志:

[10/12/2018, 17:19:56]: Traceback (most recent call last):
[10/12/2018, 17:19:56]:   File "/notebooks/models/research/object_detection/legacy/train.py", line 49, in <module>
[10/12/2018, 17:19:56]:     from object_detection.builders import dataset_builder
[10/12/2018, 17:19:56]:   File "/usr/local/lib/python2.7/dist-packages/object_detection-0.1-py2.7.egg/object_detection/builders/dataset_builder.py", line 27, in <module>
[10/12/2018, 17:19:56]:     from object_detection.data_decoders import tf_example_decoder
[10/12/2018, 17:19:56]:   File "/usr/local/lib/python2.7/dist-packages/object_detection-0.1-py2.7.egg/object_detection/data_decoders/tf_example_decoder.py", line 27, in <module>
[10/12/2018, 17:19:56]:     from object_detection.protos import input_reader_pb2
[10/12/2018, 17:19:56]: ImportError: cannot import name input_reader_pb2