Skip to content

Commit 4dab82e

Browse files
committed
chore(VR3): Generate visual recognition V3
1 parent 5cf7928 commit 4dab82e

File tree

1 file changed

+54
-35
lines changed

1 file changed

+54
-35
lines changed

watson_developer_cloud/visual_recognition_v3.py

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -106,29 +106,30 @@ def classify(self,
106106
107107
Classify images with built-in or custom classifiers.
108108
109-
:param file images_file: An image file (.jpg, .png) or .zip file with images.
110-
Maximum image size is 10 MB. Include no more than 20 images and limit the .zip
111-
file to 100 MB. Encode the image and .zip file names in UTF-8 if they contain
109+
:param file images_file: An image file (.gif, .jpg, .png, .tif) or .zip file with
110+
images. Maximum image size is 10 MB. Include no more than 20 images and limit the
111+
.zip file to 100 MB. Encode the image and .zip file names in UTF-8 if they contain
112112
non-ASCII characters. The service assumes UTF-8 encoding if it encounters
113113
non-ASCII characters.
114114
You can also include an image with the **url** parameter.
115115
:param str accept_language: The desired language of parts of the response. See the
116116
response for details.
117-
:param str url: The URL of an image to analyze. Must be in .jpg, or .png format.
118-
The minimum recommended pixel density is 32X32 pixels per inch, and the maximum
119-
image size is 10 MB.
117+
:param str url: The URL of an image (.gif, .jpg, .png, .tif) to analyze. The
118+
minimum recommended pixel density is 32X32 pixels, but the service tends to
119+
perform better with images that are at least 224 x 224 pixels. The maximum image
120+
size is 10 MB.
120121
You can also include images with the **images_file** parameter.
121122
:param float threshold: The minimum score a class must have to be displayed in the
122-
response. Set the threshold to `0.0` to ignore the classification score and return
123-
all values.
124-
:param list[str] owners: The categories of classifiers to apply. Use `IBM` to
125-
classify against the `default` general classifier, and use `me` to classify
126-
against your custom classifiers. To analyze the image against both classifier
127-
categories, set the value to both `IBM` and `me`.
128-
The built-in `default` classifier is used if both **classifier_ids** and
129-
**owners** parameters are empty.
130-
The **classifier_ids** parameter overrides **owners**, so make sure that
123+
response. Set the threshold to `0.0` to return all identified classes.
124+
:param list[str] owners: The categories of classifiers to apply. The
125+
**classifier_ids** parameter overrides **owners**, so make sure that
131126
**classifier_ids** is empty.
127+
- Use `IBM` to classify against the `default` general classifier. You get the same
128+
result if both **classifier_ids** and **owners** parameters are empty.
129+
- Use `me` to classify against all your custom classifiers. However, for better
130+
performance use **classifier_ids** to specify the specific custom classifiers to
131+
apply.
132+
- Use both `IBM` and `me` to analyze the image against both classifier categories.
132133
:param list[str] classifier_ids: Which classifiers to apply. Overrides the
133134
**owners** parameter. You can specify both custom and built-in classifier IDs. The
134135
built-in `default` classifier is used if both **classifier_ids** and **owners**
@@ -147,6 +148,8 @@ def classify(self,
147148
headers = {'Accept-Language': accept_language}
148149
if 'headers' in kwargs:
149150
headers.update(kwargs.get('headers'))
151+
headers[
152+
'X-IBMCloud-SDK-Analytics'] = 'service_name=watson_vision_combined;service_version=V3;operation_id=classify'
150153

151154
params = {'version': self.version}
152155

@@ -186,9 +189,9 @@ def classify(self,
186189
def detect_faces(self,
187190
images_file=None,
188191
url=None,
192+
accept_language=None,
189193
images_file_content_type=None,
190194
images_filename=None,
191-
accept_language=None,
192195
**kwargs):
193196
"""
194197
Detect faces in images.
@@ -202,7 +205,8 @@ def detect_faces(self,
202205
and gender. This feature uses a built-in model, so no training is necessary. The
203206
Detect faces method does not support general biometric facial recognition.
204207
Supported image formats include .gif, .jpg, .png, and .tif. The maximum image size
205-
is 10 MB. The minimum recommended pixel density is 32X32 pixels per inch.
208+
is 10 MB. The minimum recommended pixel density is 32X32 pixels, but the service
209+
tends to perform better with images that are at least 224 x 224 pixels.
206210
207211
:param file images_file: An image file (gif, .jpg, .png, .tif.) or .zip file with
208212
images. Limit the .zip file to 100 MB. You can include a maximum of 15 images in a
@@ -212,14 +216,15 @@ def detect_faces(self,
212216
characters.
213217
You can also include an image with the **url** parameter.
214218
:param str url: The URL of an image to analyze. Must be in .gif, .jpg, .png, or
215-
.tif format. The minimum recommended pixel density is 32X32 pixels per inch, and
216-
the maximum image size is 10 MB. Redirects are followed, so you can use a
219+
.tif format. The minimum recommended pixel density is 32X32 pixels, but the
220+
service tends to perform better with images that are at least 224 x 224 pixels.
221+
The maximum image size is 10 MB. Redirects are followed, so you can use a
217222
shortened URL.
218223
You can also include images with the **images_file** parameter.
219-
:param str images_file_content_type: The content type of images_file.
220-
:param str images_filename: The filename for images_file.
221224
:param str accept_language: The desired language of parts of the response. See the
222225
response for details.
226+
:param str images_file_content_type: The content type of images_file.
227+
:param str images_filename: The filename for images_file.
223228
:param dict headers: A `dict` containing the request headers
224229
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
225230
:rtype: DetailedResponse
@@ -228,6 +233,8 @@ def detect_faces(self,
228233
headers = {'Accept-Language': accept_language}
229234
if 'headers' in kwargs:
230235
headers.update(kwargs.get('headers'))
236+
headers[
237+
'X-IBMCloud-SDK-Analytics'] = 'service_name=watson_vision_combined;service_version=V3;operation_id=detect_faces'
231238

232239
params = {'version': self.version}
233240

@@ -307,6 +314,8 @@ def create_classifier(self,
307314
headers = {}
308315
if 'headers' in kwargs:
309316
headers.update(kwargs.get('headers'))
317+
headers[
318+
'X-IBMCloud-SDK-Analytics'] = 'service_name=watson_vision_combined;service_version=V3;operation_id=create_classifier'
310319

311320
params = {'version': self.version}
312321

@@ -354,6 +363,8 @@ def delete_classifier(self, classifier_id, **kwargs):
354363
headers = {}
355364
if 'headers' in kwargs:
356365
headers.update(kwargs.get('headers'))
366+
headers[
367+
'X-IBMCloud-SDK-Analytics'] = 'service_name=watson_vision_combined;service_version=V3;operation_id=delete_classifier'
357368

358369
params = {'version': self.version}
359370

@@ -385,6 +396,8 @@ def get_classifier(self, classifier_id, **kwargs):
385396
headers = {}
386397
if 'headers' in kwargs:
387398
headers.update(kwargs.get('headers'))
399+
headers[
400+
'X-IBMCloud-SDK-Analytics'] = 'service_name=watson_vision_combined;service_version=V3;operation_id=get_classifier'
388401

389402
params = {'version': self.version}
390403

@@ -412,6 +425,8 @@ def list_classifiers(self, verbose=None, **kwargs):
412425
headers = {}
413426
if 'headers' in kwargs:
414427
headers.update(kwargs.get('headers'))
428+
headers[
429+
'X-IBMCloud-SDK-Analytics'] = 'service_name=watson_vision_combined;service_version=V3;operation_id=list_classifiers'
415430

416431
params = {'version': self.version, 'verbose': verbose}
417432

@@ -432,9 +447,9 @@ def update_classifier(self,
432447
"""
433448
Update a classifier.
434449
435-
Update a custom classifier by adding new positive or negative classes (examples)
436-
or by adding new images to existing classes. You must supply at least one set of
437-
positive or negative examples. For details, see [Updating custom
450+
Update a custom classifier by adding new positive or negative classes or by adding
451+
new images to existing classes. You must supply at least one set of positive or
452+
negative examples. For details, see [Updating custom
438453
classifiers](https://cloud.ibm.com/docs/services/visual-recognition/customizing.html#updating-custom-classifiers).
439454
Encode all names in UTF-8 if they contain non-ASCII characters (.zip and image
440455
file names, and classifier and class names). The service assumes UTF-8 encoding if
@@ -476,6 +491,8 @@ def update_classifier(self,
476491
headers = {}
477492
if 'headers' in kwargs:
478493
headers.update(kwargs.get('headers'))
494+
headers[
495+
'X-IBMCloud-SDK-Analytics'] = 'service_name=watson_vision_combined;service_version=V3;operation_id=update_classifier'
479496

480497
params = {'version': self.version}
481498

@@ -530,6 +547,8 @@ def get_core_ml_model(self, classifier_id, **kwargs):
530547
headers = {}
531548
if 'headers' in kwargs:
532549
headers.update(kwargs.get('headers'))
550+
headers[
551+
'X-IBMCloud-SDK-Analytics'] = 'service_name=watson_vision_combined;service_version=V3;operation_id=get_core_ml_model'
533552

534553
params = {'version': self.version}
535554

@@ -570,6 +589,8 @@ def delete_user_data(self, customer_id, **kwargs):
570589
headers = {}
571590
if 'headers' in kwargs:
572591
headers.update(kwargs.get('headers'))
592+
headers[
593+
'X-IBMCloud-SDK-Analytics'] = 'service_name=watson_vision_combined;service_version=V3;operation_id=delete_user_data'
573594

574595
params = {'version': self.version, 'customer_id': customer_id}
575596

@@ -905,8 +926,8 @@ class Classifier(object):
905926
906927
:attr str classifier_id: ID of a classifier identified in the image.
907928
:attr str name: Name of the classifier.
908-
:attr str owner: (optional) Unique ID of the account who owns the classifier. Returned
909-
when verbose=`true`. Might not be returned by some requests.
929+
:attr str owner: (optional) Unique ID of the account who owns the classifier. Might
930+
not be returned by some requests.
910931
:attr str status: (optional) Training status of classifier.
911932
:attr bool core_ml_enabled: (optional) Whether the classifier can be downloaded as a
912933
Core ML model after the training status is `ready`.
@@ -916,11 +937,11 @@ class Classifier(object):
916937
that the classifier was created.
917938
:attr list[Class] classes: (optional) Classes that define a classifier.
918939
:attr datetime retrained: (optional) Date and time in Coordinated Universal Time (UTC)
919-
that the classifier was updated. Returned when verbose=`true`. Might not be returned
920-
by some requests. Identical to `updated` and retained for backward compatibility.
940+
that the classifier was updated. Might not be returned by some requests. Identical to
941+
`updated` and retained for backward compatibility.
921942
:attr datetime updated: (optional) Date and time in Coordinated Universal Time (UTC)
922943
that the classifier was most recently updated. The field matches either `retrained` or
923-
`created`. Returned when verbose=`true`. Might not be returned by some requests.
944+
`created`. Might not be returned by some requests.
924945
"""
925946

926947
def __init__(self,
@@ -940,7 +961,7 @@ def __init__(self,
940961
:param str classifier_id: ID of a classifier identified in the image.
941962
:param str name: Name of the classifier.
942963
:param str owner: (optional) Unique ID of the account who owns the classifier.
943-
Returned when verbose=`true`. Might not be returned by some requests.
964+
Might not be returned by some requests.
944965
:param str status: (optional) Training status of classifier.
945966
:param bool core_ml_enabled: (optional) Whether the classifier can be downloaded
946967
as a Core ML model after the training status is `ready`.
@@ -950,13 +971,11 @@ def __init__(self,
950971
(UTC) that the classifier was created.
951972
:param list[Class] classes: (optional) Classes that define a classifier.
952973
:param datetime retrained: (optional) Date and time in Coordinated Universal Time
953-
(UTC) that the classifier was updated. Returned when verbose=`true`. Might not be
954-
returned by some requests. Identical to `updated` and retained for backward
955-
compatibility.
974+
(UTC) that the classifier was updated. Might not be returned by some requests.
975+
Identical to `updated` and retained for backward compatibility.
956976
:param datetime updated: (optional) Date and time in Coordinated Universal Time
957977
(UTC) that the classifier was most recently updated. The field matches either
958-
`retrained` or `created`. Returned when verbose=`true`. Might not be returned by
959-
some requests.
978+
`retrained` or `created`. Might not be returned by some requests.
960979
"""
961980
self.classifier_id = classifier_id
962981
self.name = name

0 commit comments

Comments
 (0)