A cmdline tool for interacting with the Google Cloud Vision API. Useful for bulk jobs.
-
Create a project with the Google Cloud Console, and enable the Vision API.
-
From the Cloud Console, create a service account, download its json credentials file, then set the
GOOGLE_APPLICATION_CREDENTIALS
environment variable:export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your-project-credentials.json
- Preferred: set up an isolated Python environment. Note: On OS X El Capitain this
is required or else you will get dependency issues for the package
six
. - Install dependencies using
pip install -r requirements.txt
Read the help page:
python visionary.py --help
Apply all detection types to a local file:
python visionary.py myimage.jpg
Apply all detection types to remote file accessible over HTTP:
python visionary.py http://www.example.com/myimage.jpg
Apply all detection types to an image on Cloud Storage:
python visionary.py gs://mybucket/myimage.jpg
Apply face detection only (see --help for all types) to an image on Cloud Storage:
python visionary.py -t face_detection gs://mybucket/myimage.jpg
Bulk load images in the local directory 'input' and write output to files suffixed with ".json" in the local directory 'output':
find input -type f | python visionary.py -o output
Bulk load images from Cloud Storage and write output to files suffixed with ".json" in the local directory 'output':
gsutil ls gs://mybucket/ | python visionary.py -o output