gs://cloud-ml-data/img/flower_photos/dandelion/17388674711_6dca8a2e8b_n.jpg,dandelion gs://cloud-ml-data/img/flower_photos/sunflowers/9555824387_32b151e9b0_m.jpg,sunflowers gs://cloud-ml-data/img/flower_photos/daisy/14523675369_97c31d0b5b.jpg,daisy gs://cloud-ml-data/img/flower_photos/roses/512578026_f6e6f2ad26.jpg,roses gs://cloud-ml-data/img/flower_photos/tulips/497305666_b5d4348826_n.jpg,tulips...
daisy
0
tulips
4
daisy dandelion roses sunflowers tulips
--output_path
# Assign appropriate values. PROJECT=$(gcloud config list project --format "value(core.project)") JOB_ID="flowers_${USER}_$(date +%Y%m%d_%H%M%S)" BUCKET="gs://${PROJECT}-ml" GCS_PATH="${BUCKET}/${USER}/${JOB_ID}" DICT_FILE=gs://cloud-ml-data/img/flower_photos/dict.txt # Preprocess the eval set. python trainer/preprocess.py \ --input_dict "$DICT_FILE" \ --input_path "gs://cloud-ml-data/img/flower_photos/eval_set.csv" \ --output_path "${GCS_PATH}/preproc/eval" \ --cloud # Preprocess the train set. python trainer/preprocess.py \ --input_dict "$DICT_FILE" \ --input_path "gs://cloud-ml-data/img/flower_photos/train_set.csv" \ --output_path "${GCS_PATH}/preproc/train" \ --cloud
# Submit training job. gcloud beta ml jobs submit training "$JOB_ID" \ --module-name trainer.task \ --package-path trainer \ --staging-bucket "$BUCKET" \ --region us-central1 \ -- \ --output_path "${GCS_PATH}/training" \ --eval_data_paths "${GCS_PATH}/preproc/eval*" \ --train_data_paths "${GCS_PATH}/preproc/train*" # Monitor training logs. gcloud beta ml jobs stream-logs "$JOB_ID"
MODEL_NAME= VERSION_NAME=v1 # for example gcloud beta ml models create ${MODEL_NAME} gcloud beta ml versions create \ --origin ${GCS_PATH}/training/model/ \ --model ${MODEL_NAME} \ ${VERSION_NAME} gcloud beta ml versions set-default --model ${MODEL_NAME} ${VERSION_NAME}
# Copy the image to local disk. gsutil cp gs://cloud-ml-data/img/flower_photos/tulips/4520577328_a94c11e806_n.jpg flower.jpg # Create request message in json format. python -c 'import base64, sys, json; img = base64.b64encode(open(sys.argv[1], "rb").read()); print json.dumps({"key":"0", "image_bytes": {"b64": img}})' flower.jpg &> request.json # Call prediction service API to get classifications gcloud beta ml predict --model ${MODEL_NAME} --json-instances request.json
predictions: - key: '0' prediction: 4 scores: - 8.11998e-09 - 2.64907e-08 - 1.10307e-06 - 3.69488e-11 - 0.999999 - 3.35913e-09
tulip
0.99
0 件のコメント :
コメントを投稿