You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* You need an [IBM Cloud][ibm-cloud-onboarding] account.
36
+
10
37
## Installation
11
38
12
39
To install, use `pip` or `easy_install`:
@@ -41,70 +68,38 @@ For more details see [#405](https://github.com/watson-developer-cloud/python-sdk
41
68
42
69
## Examples
43
70
44
-
The [examples][examples] folder has basic and advanced examples.
45
-
46
-
## Getting the Service Credentials
47
-
48
-
Service credentials are required to access the APIs.
49
-
50
-
If you run your app in IBM Cloud, you don't need to specify the username and password or IAM API key (`apikey`). In that case, the SDK uses the `VCAP_SERVICES` environment variable to load the credentials.
51
-
To run locally or outside of IBM Cloud you need the `username` and `password` credentials or IAM API key (`apikey`) for each service. (Service credentials are different from your IBM Cloud account email and password.)
71
+
The [examples][examples] folder has basic and advanced examples. The examples within each service assume that you already have [service credentials](#getting-credentials).
52
72
53
-
To create an instance of the service:
73
+
## Running in IBM Cloud
54
74
55
-
1. Log in to [IBM Cloud][ibm_cloud].
56
-
1. Create an instance of the service:
57
-
1. Click on **Create Resource**.
58
-
1. In the IBM Cloud **Catalog**, select the Watson service you want to use. For example, select the Conversation service.
59
-
1. Type a unique name for the service instance in the **Service name** field. For example, type `my-service-name`. Leave the default values for the other options.
60
-
1. Click **Create**.
75
+
If you run your app in IBM Cloud, the SDK gets credentials from the [`VCAP_SERVICES`][vcap_services] environment variable.
61
76
62
77
## Authentication
63
-
To get your service credentials:
64
78
65
-
Copy your credentials from the **Manage** page. To find the Service details page for an existing service, navigate to your [IBM Cloud][ibm_cloud] dashboard and click the service name.
79
+
Watson services are migrating to token-based Identity and Access Management (IAM) authentication.
66
80
67
-
1. On the **Manage** page, you will see a **Credentials** pane
68
-
1. Depending on the service you will see use either:
69
-
* 2.a: `username`, `password`, and `url`(optional) or `apikey`(for Visual Recognition).
70
-
* 2.b: `apikey` which is the value for parameter `iam_api_key` when initializing the constructor.
- With some service instances, you authenticate to the API by using **[IAM](#iam)**.
82
+
- In other instances, you authenticate by providing the **[username and password](#username-and-password)** for the service instance.
83
+
- Visual Recognition uses a form of [API key](#api-key) only with instances created before May 23, 2018. Newer instances of Visual Recognition use IAM.
84
84
85
-
### API Key
86
-
*Important: Instantiation with API key works only with Visual Recognition service instances created before May 23, 2018. Visual Recognition instances created after May 22 use IAM.*
85
+
### Getting credentials
86
+
To find out which authentication to use, view the service credentials. You find the service credentials for authentication the same way for all Watson services:
87
87
88
-
```python
89
-
from watson_developer_cloud import VisualRecognitionV3
IBM Cloud is migrating to token-based Identity and Access Management (IAM) authentication. IAM authentication uses a service API key to get an access token that is passed with the call. Access tokens are valid for approximately one hour and must be regenerated.
101
96
102
-
When authenticating with IAM, you have the option of passing in:
97
+
You supply either an IAM service **API key** or an **access token**:
103
98
104
-
*the IAM API key and, optionally, the IAM service URL
105
-
* an IAM access token
99
+
- Use the API key to have the SDK manage the lifecycle of the access token. The SDK requests an access token, ensures that the access token is valid, and refreshes it if necessary.
100
+
- Use the access token if you want to manage the lifecycle yourself. For details, see [Authenticating with IAM tokens](https://console.bluemix.net/docs/services/watson/getting-started-iam.html).
106
101
107
-
**Be aware that passing in an access token means that you're assuming responsibility for maintaining that token's lifecycle.** If you instead pass in an IAM API key, the SDK will manage it for you.
102
+
#### Supplying the IAM API key
108
103
109
104
```python
110
105
# In the constructor, letting the SDK manage the IAM token
If at any time you would like to let the SDK take over managing your IAM token, simply override your stored IAM credentials with an IAM API key by calling the `set_token_manager()` method again.
**Important**: This type of authentication works only with Visual Recognition instances created before May 23, 2018. Newer instances of Visual Recognition use [IAM](#iam).
146
+
147
+
```python
148
+
from watson_developer_cloud import VisualRecognitionV3
Copy file name to clipboardExpand all lines: watson_developer_cloud/visual_recognition_v3.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -235,8 +235,8 @@ def create_classifier(self,
235
235
"""
236
236
Create a classifier.
237
237
:param str name: The name of the new classifier. Encode special characters in UTF-8.
238
-
:param file <NAME>_positive_examples: A compressed (.zip) file of images that depict the visual subject for a class within the new classifier. Must contain a minimum of 10 images. The swagger limits you to training only one class. To train more classes, use the API functionality.
239
-
:param file negative_examples: A compressed (.zip) file of images that do not depict the visual subject of any of the classes of the new classifier. Must contain a minimum of 10 images.
238
+
:param file <NAME>_positive_examples: A compressed (.zip) file of images that depict the visual subject for a class within the new classifier. Include at least 10 images in .jpg or .png format. The minimum recommended image resolution is 32X32 pixels. The maximum number of images is 10,000 images or 100 MB per .zip file. Encode special characters in the file name in UTF-8.
239
+
:param file negative_examples: A compressed (.zip) file of images that do not depict the visual subject of any of the classes of the new classifier. Must contain a minimum of 10 images. Encode special characters in the file name in UTF-8.
240
240
:param dict headers: A `dict` containing the request headers
241
241
:return: A `dict` containing the `Classifier` response.
242
242
:rtype: dict
@@ -339,8 +339,8 @@ def update_classifier(self,
339
339
"""
340
340
Update a classifier.
341
341
:param str classifier_id: The ID of the classifier.
342
-
:param file <NAME>_positive_examples: A compressed (.zip) file of images that depict the visual subject for a class within the classifier. Must contain a minimum of 10 images.
343
-
:param file negative_examples: A compressed (.zip) file of images that do not depict the visual subject of any of the classes of the new classifier. Must contain a minimum of 10 images.
342
+
:param file <NAME>_positive_examples: A .zip file of images that depict the visual subject of a class in the classifier. The positive examples create or update classes in the classifier. You can include more than one positive example file in a call. Include at least 10 images in .jpg or .png format. The minimum recommended image resolution is 32X32 pixels. The maximum number of images is 10,000 images or 100 MB per .zip file. Encode special characters in the file name in UTF-8.
343
+
:param file negative_examples: A .zip file of images that do not depict the visual subject of any of the classes of the new classifier. Must contain a minimum of 10 images. Encode special characters in the file name in UTF-8.
344
344
:param dict headers: A `dict` containing the request headers
345
345
:return: A `dict` containing the `Classifier` response.
0 commit comments