|
1 | 1 | Python Client for Google Cloud Vision
|
2 | 2 | =====================================
|
3 | 3 |
|
4 |
| - Python idiomatic client for `Google Cloud Vision`_ |
| 4 | +|pypi| |versions| |
5 | 5 |
|
6 |
| -.. _Google Cloud Vision: https://cloud.google.com/vision/ |
| 6 | +The `Google Cloud Vision`_ API enables developers to |
| 7 | +understand the content of an image by encapsulating powerful machine |
| 8 | +learning models in an easy to use REST API. It quickly classifies images |
| 9 | +into thousands of categories (e.g., "sailboat", "lion", "Eiffel Tower"), |
| 10 | +detects individual objects and faces within images, and finds and reads |
| 11 | +printed words contained within images. You can build metadata on your |
| 12 | +image catalog, moderate offensive content, or enable new marketing |
| 13 | +scenarios through image sentiment analysis. Analyze images uploaded |
| 14 | +in the request or integrate with your image storage on Google Cloud |
| 15 | +Storage. |
7 | 16 |
|
8 |
| -|pypi| |versions| |
| 17 | +- `Client Library Documentation`_ |
| 18 | +- `Product Documentation`_ |
9 | 19 |
|
10 |
| -- `Documentation`_ |
| 20 | +.. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-vision.svg |
| 21 | + :target: https://pypi.org/project/google-cloud-vision/ |
| 22 | +.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-vision.svg |
| 23 | + :target: https://pypi.org/project/google-cloud-vision/ |
| 24 | +.. _Vision: https://cloud.google.com/vision/ |
| 25 | + |
| 26 | +.. _Google Cloud Vision: https://cloud.google.com/vision/ |
| 27 | +.. _Client Library Documentation: https://googlecloudplatform.github.io/google-cloud-python/latest/vision/ |
| 28 | +.. _Product Documentation: https://cloud.google.com/vision/reference/rest/ |
11 | 29 |
|
12 |
| -.. _Documentation: https://googlecloudplatform.github.io/google-cloud-python/latest/vision/ |
13 | 30 |
|
14 | 31 | Quick Start
|
15 | 32 | -----------
|
16 | 33 |
|
| 34 | +In order to use this library, you first need to go through the following steps: |
| 35 | + |
| 36 | +1. `Select or create a Cloud Platform project.`_ |
| 37 | +2. `Enable billing for your project.`_ |
| 38 | +3. `Enable the Google Cloud Vision API.`_ |
| 39 | +4. `Setup Authentication.`_ |
| 40 | + |
| 41 | +.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project |
| 42 | +.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project |
| 43 | +.. _Enable the Google Cloud Vision API.: https://cloud.google.com/vision |
| 44 | +.. _Setup Authentication.: https://googlecloudplatform.github.io/google-cloud-python/latest/core/auth.html |
| 45 | + |
| 46 | +Installation |
| 47 | +~~~~~~~~~~~~ |
| 48 | + |
| 49 | +Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to |
| 50 | +create isolated Python environments. The basic problem it addresses is one of |
| 51 | +dependencies and versions, and indirectly permissions. |
| 52 | + |
| 53 | +With `virtualenv`_, it's possible to install this library without needing system |
| 54 | +install permissions, and without clashing with the installed system |
| 55 | +dependencies. |
| 56 | + |
| 57 | +.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ |
| 58 | + |
| 59 | + |
| 60 | +Mac/Linux |
| 61 | +^^^^^^^^^ |
| 62 | + |
17 | 63 | .. code-block:: console
|
18 | 64 |
|
19 |
| - $ pip install --upgrade google-cloud-vision |
| 65 | + pip install virtualenv |
| 66 | + virtualenv <your-env> |
| 67 | + source <your-env>/bin/activate |
| 68 | + <your-env>/bin/pip install google-cloud-vision |
20 | 69 |
|
21 |
| -For more information on setting up your Python development environment, |
22 |
| -such as installing ``pip`` and ``virtualenv`` on your system, please refer |
23 |
| -to `Python Development Environment Setup Guide`_ for Google Cloud Platform. |
24 | 70 |
|
25 |
| -.. _Python Development Environment Setup Guide: https://cloud.google.com/python/setup |
| 71 | +Windows |
| 72 | +^^^^^^^ |
26 | 73 |
|
27 |
| -Authentication |
28 |
| --------------- |
| 74 | +.. code-block:: console |
29 | 75 |
|
30 |
| -With ``google-cloud-python`` we try to make authentication as painless as |
31 |
| -possible. Check out the `Authentication section`_ in our documentation to |
32 |
| -learn more. You may also find the `authentication document`_ shared by all |
33 |
| -the ``google-cloud-*`` libraries to be helpful. |
| 76 | + pip install virtualenv |
| 77 | + virtualenv <your-env> |
| 78 | + <your-env>\Scripts\activate |
| 79 | + <your-env>\Scripts\pip.exe install google-cloud-vision |
34 | 80 |
|
35 |
| -.. _Authentication section: https://google-cloud-python.readthedocs.io/en/latest/core/auth.html |
36 |
| -.. _authentication document: https://github.com/GoogleCloudPlatform/google-cloud-common/tree/master/authentication |
37 | 81 |
|
38 |
| -Using the API |
39 |
| -------------- |
| 82 | +Example Usage |
| 83 | +~~~~~~~~~~~~~ |
40 | 84 |
|
41 |
| -The Google Cloud `Vision`_ (`Vision API docs`_) API enables developers to |
42 |
| -understand the content of an image by encapsulating powerful machine |
43 |
| -learning models in an easy to use REST API. It quickly classifies images |
44 |
| -into thousands of categories (e.g., "sailboat", "lion", "Eiffel Tower"), |
45 |
| -detects individual objects and faces within images, and finds and reads |
46 |
| -printed words contained within images. You can build metadata on your |
47 |
| -image catalog, moderate offensive content, or enable new marketing |
48 |
| -scenarios through image sentiment analysis. Analyze images uploaded |
49 |
| -in the request or integrate with your image storage on Google Cloud |
50 |
| -Storage. |
| 85 | +.. code-block:: python |
51 | 86 |
|
52 |
| -.. _Vision: https://cloud.google.com/vision/ |
53 |
| -.. _Vision API docs: https://cloud.google.com/vision/reference/rest/ |
| 87 | + from google.cloud import vision |
54 | 88 |
|
55 |
| -See the ``google-cloud-python`` API `Documentation`_ to learn |
56 |
| -how to analyze images using this library. |
| 89 | + client = vision.ImageAnnotatorClient() |
| 90 | + response = client.annotate_image({ |
| 91 | + 'image': {'source': {'image_uri': 'gs://my-test-bucket/image.jpg'}}, |
| 92 | + 'features': [{'type': vision.enums.Feature.Type.FACE_DETECTION}], |
| 93 | + }) |
57 | 94 |
|
58 |
| -.. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-vision.svg |
59 |
| - :target: https://pypi.org/project/google-cloud-vision/ |
60 |
| -.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-vision.svg |
61 |
| - :target: https://pypi.org/project/google-cloud-vision/ |
| 95 | +Next Steps |
| 96 | +~~~~~~~~~~ |
| 97 | + |
| 98 | +- Read the `Client Library Documentation`_ for Google Cloud Vision API |
| 99 | + API to see other available methods on the client. |
| 100 | +- Read the `Product documentation`_ to learn |
| 101 | + more about the product and see How-to Guides. |
0 commit comments