The Schaubies' Story |||

gcloud Vision API Example

Prerequisites

As a start it is a good practise to create a project folder and create a virtual environment.

Create the environment like this:

python3 -m virtualenv your-virtual-env

activate it with:

source your-virtual-env/bin/activate

Option 1 - REST API

Follow this guide to get started and try the vision API using the command line. https://cloud.google.com/vision/docs/quickstart-cli

Use this python script to get a request json you can send to the Vision API.

You can use the script like this:

python image2request_json.py path/to/your/img

Make the request:

curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
https://vision.googleapis.com/v1/images:annotate -d @your-request.json > your-response.json

Option 2 - Client Libraries

The Quickstart guide for using the client libraries can be found here:
https://cloud.google.com/vision/docs/quickstart-client-libraries

Use this python script to directly request the data via python and get a reduced json, that only includes recognized labels/objects and the scores they have.

python vision_request.py path/to/your/img

Robert, July 16th, 2020

Up next day#4 day#5
Latest posts The Last Schaubie Chain story Live with a computer vision software Baby steps with our own vision AI Telling worlds the technology of collaborative work, and other feelings Boxes, Boxes Everywhere Connecting the dots do sheep dream of fluffy robots? The cat and the musician week#3 games x3 21282 sci-fi images (for neural-network training) Narration Image Description and Restaging Trying the google vision API with drawings day#5 gcloud Vision API Example day#4 day#3 flag day#2 day#1