求助大神,刚入手java,最近在做一个jar包,要调用之前写好的python脚本,有一些问题不会。

u010271151 2018-06-12 03:11:12
python脚本中的命令行参数在训练时部分需要不断的修改,用java调用时如何传递给python脚本这些命令行参数?下面是调用我这个python工程的train.py文件的部分命令行参数和写的调用这个train.py的java方法。
parser.add_argument(
'--experiment_root', default='./zcheckpoints', type=common.writeable_directory,
help='Location used to store checkpoints and dumped data.')

parser.add_argument(
'--train_set',default = 'data/mnist_train.csv',
help='Path to the train_set csv file.')

parser.add_argument(
'--image_root', default = '/home/dl/triplet-reid1/data/mnist',type=common.readable_directory,
help='Path that will be pre-pended to the filenames in the train_set csv.')
java调用的函数:
public static void train(String Epath,String Tpath,String Ipath,int batchp,int TI,int DI,int CF){
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.execfile("/home/dl/triplet-reid1/train.py");
PyFunction function = (PyFunction)interpreter.get("main");
PyObject pyobject = function.__call__(new PyString(Epath),new PyString(Tpath),new PyString(Ipath),new PyInteger(batchp),new PyInteger(TI),new PyInteger(DI),new PyInteger(CF));
System.out.println(pyobject);
}而且这个call函数的参数还报错。
求大神指教,新手,之前都没接触过java,周围貌似也没人会。
...全文
730 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

51,410

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧