Where to place 'input.json file' when do Google Cloud Machine Learning engine prediction?

人盡茶涼 提交于 2021-01-29 22:33:50

问题


I am using Google Cloud ML Engine to do local prediction by run:

gcloud ml-engine local predict --model-dir=$MODEL_DIR --json-instances $INPUT_FILE --framework $FRAMEWORK

assume:

MODEL_DIR="gs://<bucket>/model.joblib"
FRAMEWORK="SCIKIT_LEARN"

input file input.json is in hardisk (d:\predict)

How to specify: INPUT_FILE=?

I have manually upload the input file into my gc bucket, but get error:

ERROR: (gcloud.ml-engine.local.predict) Unable to read file [gs://<bucket>/input.json]: [Errno 2] No such file or directory: 'gs://<bucket>/input.json

Where shall I place the input file?

shall I keep it as in local disk (e.g. d:\predit\input.json) or in bucket?

And what format is this?


回答1:


You are setting the MODEL_DIR wrong, there is no need of adding "model.joblib" as it will be detected automatically. MODEL_DIR should contain the path (including folders if necessary) where the file "model.joblib" is. As good practise, it's common to have a bucket containing it. The command (for your case) should go like this :

  MODEL_DIR="gs://<bucket>/"
  INPUT_FILE="input.json"
  FRAMEWORK="SCIKIT_LEARN"

and your bucket should contain "model.joblib". For INPUT_FILE, it should contain the path where "input.json" is FROM where you are running the command and the ".json" itself (i.e, if the ".json" it's under other folder, INPUT_FILE should be "< folder>/input.json").

Here is the documentation for testing models [1].



来源:https://stackoverflow.com/questions/51469894/where-to-place-input-json-file-when-do-google-cloud-machine-learning-engine-pr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!