如何从 Unix 可执行文件导出结果?

How to export result from Unix executable?

我是 运行 来自 this 伟大的图像质量评估库的深度学习推理:

./predict  \
--docker-image nima-cpu \
--base-model-name MobileNet \
--weights-file $(pwd)/models/MobileNet/weights_mobilenet_technical_0.11.hdf5 \
--image-source $(pwd)/src/tests/test_images

运行 predict,这是一个 Unix 可执行文件,returns 以下示例输出:

[
  {
    "image_id": "42039",
    "mean_score_prediction": 5.154480201676051
  },
  {
    "image_id": "42040",
    "mean_score_prediction": 4.297615758532629
  },
  {
    "image_id": "42041",
    "mean_score_prediction": 5.450399260735139
  },
  {
    "image_id": "42042",
    "mean_score_prediction": 5.163813116261736
  },
  {
    "image_id": "42044",
    "mean_score_prediction": 5.728919437354534
  }
] 

我正在尝试保存此输出,最好保存到 json,但不知道如何保存。附加 --output $(pwd)/src/out.jsonoutput 的任何变体 return 没有任何意义。

Unix exe 是否有用于导出数据的默认标志?或者有没有办法查看此 exe 中的所有标志选项?

看起来 predict 是一个 bash 脚本。没有关于参数应该如何工作的规则。我只是将您的输出通过管道传输到这样的文件中:

./predict  \
--docker-image nima-cpu \
--base-model-name MobileNet \
--weights-file $(pwd)/models/MobileNet/weights_mobilenet_technical_0.11.hdf5 \
--image-source $(pwd)/src/tests/test_images
> output.json

最后一部分告诉您的终端将标准输出(通常会在您的屏幕上显示的内容)发送到提到的文件,创建它或覆盖它。