【问题标题】:How to export result from Unix executable?如何从 Unix 可执行文件中导出结果?
【发布时间】:2021-12-25 11:23:50
【问题描述】:

我正在从 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 可执行文件,返回以下示例输出:

[
  {
    "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 的任何变体不会返回任何内容。

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

【问题讨论】:

    标签: python json python-3.x unix save


    【解决方案1】:

    看起来 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
    

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

    【讨论】:

      猜你喜欢
      • 2017-04-13
      • 2011-04-26
      • 1970-01-01
      • 2020-07-10
      • 2015-12-31
      • 1970-01-01
      • 1970-01-01
      • 2019-02-01
      • 2016-09-06
      相关资源
      最近更新 更多