Skip to content

Commit 5ff8dd3

Browse files
authored
:fix (VR): bug fixes in VR (#434)
* :fix (VR): bug fixes in VR * :fix(VR): owners instance of list
1 parent ba49604 commit 5ff8dd3

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

examples/microphone-speech-to-text.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# You need to install pyaudio to run this example
22
# pip install pyaudio
33

4+
# Note that you need to record just once. You will not be able to send
5+
# more audio after the initial recording.
6+
47
from __future__ import print_function
58
import pyaudio
69
import tempfile

examples/visual_recognition_v3.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import print_function
22
import json
33
from os.path import join, dirname
4-
from watson_developer_cloud import VisualRecognitionV3
4+
from watson_developer_cloud import VisualRecognitionV3, WatsonApiException
55

66
test_url = 'https://www.ibm.com/ibm/ginni/images' \
77
'/ginni_bio_780x981_v4_03162016.jpg'
@@ -24,6 +24,17 @@
2424
parameters=parameters)
2525
print(json.dumps(car_results, indent=2))
2626

27+
# Example with no deprecated
28+
try:
29+
with open(car_path, 'rb') as images_file:
30+
car_results = visual_recognition.classify(
31+
images_file=images_file,
32+
threshold='0.1',
33+
classifier_ids=[classifier_id, 'default'])
34+
print(json.dumps(car_results, indent=2))
35+
except WatsonApiException as ex:
36+
print(ex.httpResponse.json())
37+
2738
# print(json.dumps(visual_recognition.get_classifier('YOUR CLASSIFIER ID'),
2839
# indent=2))
2940

@@ -56,6 +67,7 @@
5667
print(json.dumps(face_result, indent=2))
5768

5869
#Core ml model example
59-
core_ml_model = visual_recognition.get_core_ml_model(classifier_id)
60-
with open('/tmp/CarsvsTrucks.mlmodel', 'wb') as fp:
61-
fp.write(core_ml_model.content)
70+
# model_name = '{0}.mlmodel'.format(classifier_id)
71+
# core_ml_model = visual_recognition.get_core_ml_model(classifier_id)
72+
# with open('/tmp/{0}'.format(model_name), 'wb') as fp:
73+
# fp.write(core_ml_model.content)

watson_developer_cloud/visual_recognition_v3.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,13 @@ def classify(self,
118118
threshold_tuple = (None, threshold, 'application/json')
119119
owners_tuple = None
120120
if owners:
121+
if isinstance(owners, (list,)):
122+
owners = ','.join(owners)
121123
owners_tuple = (None, owners, 'application/json')
122124
classifier_ids_tuple = None
123125
if classifier_ids:
126+
if isinstance(classifier_ids, (list,)):
127+
classifier_ids = ','.join(classifier_ids)
124128
classifier_ids_tuple = (None, classifier_ids, 'application/json')
125129
url = '/v3/classify'
126130
response = self.request(

0 commit comments

Comments
 (0)