我试图在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