【发布时间】:2017-03-08 04:30:35
【问题描述】:
标题有点难解释,请看下面:
我用来调用 caffe 函数的 bash 脚本,这个特定的示例使用求解器 prototxt 训练模型:
#!/bin/bash
TOOLS=../../build/tools
export HDF5_DISABLE_VERSION_CHECK=1
export PYTHONPATH=.
#for debugging python layer
GLOG_logtostderr=1 $TOOLS/caffe train -solver lstm_solver_flow.prototxt -weights single_frame_all_layers_hyb_flow_iter_50000.caffemodel
echo "Done."
我已经用过很多次了,没有问题。它所做的是使用 caffe 框架的内置函数,例如“训练”和传递参数。训练代码主要使用 C++ 构建,但它为自定义数据层调用 Python 脚本。有了shell,一切都可以顺利进行。
现在,我使用带有 Shell=True 的 subprocess.call() 在 python 脚本中调用这些确切的命令
import subprocess
subprocess.call("export HDF5_DISABLE_VERSION_CHECK=1",shell=True))
subprocess.call("export PYTHONPATH=.",shell=True))
#for debugging python layer
subprocess.call("GLOG_logtostderr=1 sampleexact/samplepath/build/tools/caffe train -solver lstm_solver_flow.prototxt -weights single_frame_all_layers_hyb_flow_iter_50000.caffemodel",shell=True))
从 python 脚本 (init) 中运行 bash 命令时,它能够启动 train 进程,但是 train 进程调用另一个 python 模块以获取自定义层,但找不到它。 init 和自定义层模块都在同一个文件夹中。
我该如何解决这个问题?我真的需要从 Python 运行它,以便我可以调试。有没有办法使项目中的 -any- python 模块可以访问其他人的任何调用?
【问题讨论】: