Skip to content

Commit ffd100c

Browse files
committed
chore(VR): regenerate visual recognition
1 parent 0d637b3 commit ffd100c

1 file changed

Lines changed: 31 additions & 9 deletions

File tree

watson_developer_cloud/visual_recognition_v3.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,27 +130,30 @@ def detect_faces(self,
130130
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
131131
:rtype: DetailedResponse
132132
"""
133+
133134
headers = {}
134135
if 'headers' in kwargs:
135136
headers.update(kwargs.get('headers'))
137+
136138
params = {'version': self.version}
137-
images_file_tuple = None
139+
140+
form_data = {}
138141
if images_file:
139142
if not images_filename and hasattr(images_file, 'name'):
140143
images_filename = images_file.name
141-
mime_type = images_file_content_type or 'application/octet-stream'
142-
images_file_tuple = (images_filename, images_file, mime_type)
143-
url_tuple = None
144+
form_data['images_file'] = (images_filename, images_file,
145+
images_file_content_type or
146+
'application/octet-stream')
144147
if url:
145-
url_tuple = (None, url)
148+
form_data['url'] = (None, url)
149+
146150
url = '/v3/detect_faces'
147151
response = self.request(
148152
method='POST',
149153
url=url,
150154
headers=headers,
151155
params=params,
152-
files={'images_file': images_file_tuple,
153-
'url': url_tuple},
156+
files=form_data,
154157
accept_json=True)
155158
return response
156159

@@ -168,12 +171,16 @@ def delete_classifier(self, classifier_id, **kwargs):
168171
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
169172
:rtype: DetailedResponse
170173
"""
174+
171175
if classifier_id is None:
172176
raise ValueError('classifier_id must be provided')
177+
173178
headers = {}
174179
if 'headers' in kwargs:
175180
headers.update(kwargs.get('headers'))
181+
176182
params = {'version': self.version}
183+
177184
url = '/v3/classifiers/{0}'.format(
178185
*self._encode_path_vars(classifier_id))
179186
response = self.request(
@@ -195,12 +202,16 @@ def get_classifier(self, classifier_id, **kwargs):
195202
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
196203
:rtype: DetailedResponse
197204
"""
205+
198206
if classifier_id is None:
199207
raise ValueError('classifier_id must be provided')
208+
200209
headers = {}
201210
if 'headers' in kwargs:
202211
headers.update(kwargs.get('headers'))
212+
203213
params = {'version': self.version}
214+
204215
url = '/v3/classifiers/{0}'.format(
205216
*self._encode_path_vars(classifier_id))
206217
response = self.request(
@@ -221,10 +232,13 @@ def list_classifiers(self, verbose=None, **kwargs):
221232
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
222233
:rtype: DetailedResponse
223234
"""
235+
224236
headers = {}
225237
if 'headers' in kwargs:
226238
headers.update(kwargs.get('headers'))
239+
227240
params = {'version': self.version, 'verbose': verbose}
241+
228242
url = '/v3/classifiers'
229243
response = self.request(
230244
method='GET',
@@ -251,12 +265,16 @@ def get_core_ml_model(self, classifier_id, **kwargs):
251265
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
252266
:rtype: DetailedResponse
253267
"""
268+
254269
if classifier_id is None:
255270
raise ValueError('classifier_id must be provided')
271+
256272
headers = {}
257273
if 'headers' in kwargs:
258274
headers.update(kwargs.get('headers'))
275+
259276
params = {'version': self.version}
277+
260278
url = '/v3/classifiers/{0}/core_ml_model'.format(
261279
*self._encode_path_vars(classifier_id))
262280
response = self.request(
@@ -287,12 +305,16 @@ def delete_user_data(self, customer_id, **kwargs):
287305
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
288306
:rtype: DetailedResponse
289307
"""
308+
290309
if customer_id is None:
291310
raise ValueError('customer_id must be provided')
311+
292312
headers = {}
293313
if 'headers' in kwargs:
294314
headers.update(kwargs.get('headers'))
315+
295316
params = {'version': self.version, 'customer_id': customer_id}
317+
296318
url = '/v3/user_data'
297319
response = self.request(
298320
method='DELETE',
@@ -617,7 +639,7 @@ class Classifier(object):
617639
:attr str status: (optional) Training status of classifier.
618640
:attr bool core_ml_enabled: (optional) Whether the classifier can be downloaded as a
619641
Core ML model after the training status is `ready`.
620-
:attr str explanation: (optional) If classifier training has failed, this field may
642+
:attr str explanation: (optional) If classifier training has failed, this field might
621643
explain why.
622644
:attr datetime created: (optional) Date and time in Coordinated Universal Time (UTC)
623645
that the classifier was created.
@@ -652,7 +674,7 @@ def __init__(self,
652674
:param bool core_ml_enabled: (optional) Whether the classifier can be downloaded
653675
as a Core ML model after the training status is `ready`.
654676
:param str explanation: (optional) If classifier training has failed, this field
655-
may explain why.
677+
might explain why.
656678
:param datetime created: (optional) Date and time in Coordinated Universal Time
657679
(UTC) that the classifier was created.
658680
:param list[Class] classes: (optional) Classes that define a classifier.

0 commit comments

Comments
 (0)