简体   繁体   中英

How to export result from Unix executable?

I'm running deep learning inference from this great image quality assessment library:

./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

Running predict , which is a Unix Executable, returns the following sample output:

[
  {
    "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
  }
] 

I'm trying to save this output, ideally to json, but don't know how. Appending --output $(pwd)/src/out.json , or any variants of output , doesn't return anything.

Do Unix exe's have a default flag for exporting data? Or is there a way to view all the flag options in this exe?

Looks like predict is a bash script. There's no rule on how the arguments should work. I would just pipe your output to a file like 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
> output.json

The last part tells your terminal to send stdout (what would normally show in your screen) to the mentioned file, either creating it or overwriting it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM