ibm_watson 1.0.0.rc2 → 1.0.0.rc3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +33 -27
- data/lib/ibm_watson/assistant_v1.rb +6 -80
- data/lib/ibm_watson/assistant_v2.rb +6 -38
- data/lib/ibm_watson/compare_comply_v1.rb +6 -47
- data/lib/ibm_watson/discovery_v1.rb +12 -297
- data/lib/ibm_watson/language_translator_v3.rb +6 -41
- data/lib/ibm_watson/natural_language_classifier_v1.rb +6 -35
- data/lib/ibm_watson/natural_language_understanding_v1.rb +6 -38
- data/lib/ibm_watson/personality_insights_v3.rb +6 -30
- data/lib/ibm_watson/speech_to_text_v1.rb +9 -130
- data/lib/ibm_watson/text_to_speech_v1.rb +6 -50
- data/lib/ibm_watson/tone_analyzer_v3.rb +6 -31
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +8 -103
- data/lib/ibm_watson/websocket/speech_to_text_websocket_listener.rb +5 -5
- data/lib/ibm_watson.rb +9 -0
- data/test/integration/test_assistant_v1.rb +1 -1
- data/test/integration/test_assistant_v2.rb +1 -1
- data/test/integration/test_compare_comply_v1.rb +1 -1
- data/test/integration/test_discovery_v1.rb +1 -4
- data/test/integration/test_language_translator_v3.rb +1 -1
- data/test/integration/test_natural_language_classifier_v1.rb +1 -1
- data/test/integration/test_natural_language_understanding_v1.rb +1 -1
- data/test/integration/test_personality_insights_v3.rb +1 -1
- data/test/integration/test_speech_to_text_v1.rb +2 -2
- data/test/integration/test_text_to_speech_v1.rb +1 -1
- data/test/integration/test_tone_analyzer_v3.rb +1 -1
- data/test/integration/test_visual_recognition_v3.rb +1 -8
- data/test/unit/test_assistant_v1.rb +45 -45
- data/test/unit/test_assistant_v2.rb +3 -3
- data/test/unit/test_compare_comply_v1.rb +12 -12
- data/test/unit/test_configure_http_client.rb +37 -13
- data/test/unit/test_discovery_v1.rb +47 -139
- data/test/unit/test_language_translator_v3.rb +13 -26
- data/test/unit/test_natural_language_classifier_v1.rb +2 -2
- data/test/unit/test_natural_language_understanding_v1.rb +5 -5
- data/test/unit/test_personality_insights_v3.rb +8 -8
- data/test/unit/test_speech_to_text_v1.rb +21 -21
- data/test/unit/test_text_to_speech_v1.rb +5 -5
- data/test/unit/test_tone_analyzer_v3.rb +9 -9
- data/test/unit/test_vcap_using_personality_insights.rb +8 -8
- data/test/unit/test_visual_recognition_v3.rb +8 -75
- metadata +4 -4
@@ -15,8 +15,8 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
# The IBM Watson™ Visual Recognition service uses deep learning algorithms to
|
18
|
-
# identify scenes
|
19
|
-
#
|
18
|
+
# identify scenes and objects in images that you upload to the service. You can create and
|
19
|
+
# train a custom classifier to identify subjects that suit your needs.
|
20
20
|
|
21
21
|
require "concurrent"
|
22
22
|
require "erb"
|
@@ -45,34 +45,21 @@ module IBMWatson
|
|
45
45
|
# Instead, specify a version date that is compatible with your
|
46
46
|
# application, and don't change it until your application is
|
47
47
|
# ready for a later version.
|
48
|
-
# @option args
|
49
|
-
#
|
50
|
-
#
|
51
|
-
# @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
|
52
|
-
# this API key is provided, the SDK will manage the token and handle the
|
53
|
-
# refreshing.
|
54
|
-
# @option args iam_access_token [String] An IAM access token is fully managed by the application.
|
55
|
-
# Responsibility falls on the application to refresh the token, either before
|
56
|
-
# it expires or reactively upon receiving a 401 from the service as any requests
|
57
|
-
# made with an expired token will fail.
|
58
|
-
# @option args iam_url [String] An optional URL for the IAM service API. Defaults to
|
59
|
-
# 'https://iam.cloud.ibm.com/identity/token'.
|
60
|
-
# @option args iam_client_id [String] An optional client id for the IAM service API.
|
61
|
-
# @option args iam_client_secret [String] An optional client secret for the IAM service API.
|
62
|
-
# @option args authentication_type [STRING] Specifies the authentication pattern to use. Values that it
|
63
|
-
# takes are basic, iam or icp4d.
|
48
|
+
# @option args service_url [String] The base service URL to use when contacting the service.
|
49
|
+
# The base service_url may differ between IBM Cloud regions.
|
50
|
+
# @option args authenticator [Object] The Authenticator instance to be configured for this service.
|
64
51
|
def initialize(args = {})
|
65
52
|
@__async_initialized__ = false
|
66
53
|
defaults = {}
|
67
54
|
defaults[:version] = nil
|
68
|
-
defaults[:
|
55
|
+
defaults[:service_url] = "https://gateway.watsonplatform.net/visual-recognition/api"
|
69
56
|
defaults[:authenticator] = nil
|
70
|
-
defaults[:authentication_type] = nil
|
71
57
|
args = defaults.merge(args)
|
72
58
|
@version = args[:version]
|
73
59
|
raise ArgumentError.new("version must be provided") if @version.nil?
|
74
60
|
|
75
|
-
args[:
|
61
|
+
args[:service_name] = "visual_recognition"
|
62
|
+
args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
|
76
63
|
super
|
77
64
|
end
|
78
65
|
|
@@ -152,81 +139,6 @@ module IBMWatson
|
|
152
139
|
|
153
140
|
method_url = "/v3/classify"
|
154
141
|
|
155
|
-
headers = authenticator.authenticate(headers)
|
156
|
-
response = request(
|
157
|
-
method: "POST",
|
158
|
-
url: method_url,
|
159
|
-
headers: headers,
|
160
|
-
params: params,
|
161
|
-
form: form_data,
|
162
|
-
accept_json: true
|
163
|
-
)
|
164
|
-
response
|
165
|
-
end
|
166
|
-
#########################
|
167
|
-
# Face
|
168
|
-
#########################
|
169
|
-
|
170
|
-
##
|
171
|
-
# @!method detect_faces(images_file: nil, images_filename: nil, images_file_content_type: nil, url: nil, accept_language: nil)
|
172
|
-
# Detect faces in images.
|
173
|
-
# **Important:** On April 2, 2018, the identity information in the response to calls
|
174
|
-
# to the Face model was removed. The identity information refers to the `name` of
|
175
|
-
# the person, `score`, and `type_hierarchy` knowledge graph. For details about the
|
176
|
-
# enhanced Face model, see the [Release
|
177
|
-
# notes](https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-recognition-release-notes#2april2018).
|
178
|
-
#
|
179
|
-
# Analyze and get data about faces in images. Responses can include estimated age
|
180
|
-
# and gender. This feature uses a built-in model, so no training is necessary. The
|
181
|
-
# **Detect faces** method does not support general biometric facial recognition.
|
182
|
-
#
|
183
|
-
# Supported image formats include .gif, .jpg, .png, and .tif. The maximum image size
|
184
|
-
# is 10 MB. The minimum recommended pixel density is 32X32 pixels, but the service
|
185
|
-
# tends to perform better with images that are at least 224 x 224 pixels.
|
186
|
-
# @param images_file [File] An image file (gif, .jpg, .png, .tif.) or .zip file with images. Limit the .zip
|
187
|
-
# file to 100 MB. You can include a maximum of 15 images in a request.
|
188
|
-
#
|
189
|
-
# Encode the image and .zip file names in UTF-8 if they contain non-ASCII
|
190
|
-
# characters. The service assumes UTF-8 encoding if it encounters non-ASCII
|
191
|
-
# characters.
|
192
|
-
#
|
193
|
-
# You can also include an image with the **url** parameter.
|
194
|
-
# @param images_filename [String] The filename for images_file.
|
195
|
-
# @param images_file_content_type [String] The content type of images_file.
|
196
|
-
# @param url [String] The URL of an image to analyze. Must be in .gif, .jpg, .png, or .tif format. The
|
197
|
-
# minimum recommended pixel density is 32X32 pixels, but the service tends to
|
198
|
-
# perform better with images that are at least 224 x 224 pixels. The maximum image
|
199
|
-
# size is 10 MB. Redirects are followed, so you can use a shortened URL.
|
200
|
-
#
|
201
|
-
# You can also include images with the **images_file** parameter.
|
202
|
-
# @param accept_language [String] The desired language of parts of the response. See the response for details.
|
203
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
204
|
-
def detect_faces(images_file: nil, images_filename: nil, images_file_content_type: nil, url: nil, accept_language: nil)
|
205
|
-
headers = {
|
206
|
-
"Accept-Language" => accept_language
|
207
|
-
}
|
208
|
-
sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V3", "detect_faces")
|
209
|
-
headers.merge!(sdk_headers)
|
210
|
-
|
211
|
-
params = {
|
212
|
-
"version" => @version
|
213
|
-
}
|
214
|
-
|
215
|
-
form_data = {}
|
216
|
-
|
217
|
-
unless images_file.nil?
|
218
|
-
unless images_file.instance_of?(StringIO) || images_file.instance_of?(File)
|
219
|
-
images_file = images_file.respond_to?(:to_json) ? StringIO.new(images_file.to_json) : StringIO.new(images_file)
|
220
|
-
end
|
221
|
-
images_filename = images_file.path if images_filename.nil? && images_file.respond_to?(:path)
|
222
|
-
form_data[:images_file] = HTTP::FormData::File.new(images_file, content_type: images_file_content_type.nil? ? "application/octet-stream" : images_file_content_type, filename: images_filename)
|
223
|
-
end
|
224
|
-
|
225
|
-
form_data[:url] = HTTP::FormData::Part.new(url.to_s, content_type: "text/plain") unless url.nil?
|
226
|
-
|
227
|
-
method_url = "/v3/detect_faces"
|
228
|
-
|
229
|
-
headers = authenticator.authenticate(headers)
|
230
142
|
response = request(
|
231
143
|
method: "POST",
|
232
144
|
url: method_url,
|
@@ -316,7 +228,6 @@ module IBMWatson
|
|
316
228
|
|
317
229
|
method_url = "/v3/classifiers"
|
318
230
|
|
319
|
-
headers = authenticator.authenticate(headers)
|
320
231
|
response = request(
|
321
232
|
method: "POST",
|
322
233
|
url: method_url,
|
@@ -347,7 +258,6 @@ module IBMWatson
|
|
347
258
|
|
348
259
|
method_url = "/v3/classifiers"
|
349
260
|
|
350
|
-
headers = authenticator.authenticate(headers)
|
351
261
|
response = request(
|
352
262
|
method: "GET",
|
353
263
|
url: method_url,
|
@@ -378,7 +288,6 @@ module IBMWatson
|
|
378
288
|
|
379
289
|
method_url = "/v3/classifiers/%s" % [ERB::Util.url_encode(classifier_id)]
|
380
290
|
|
381
|
-
headers = authenticator.authenticate(headers)
|
382
291
|
response = request(
|
383
292
|
method: "GET",
|
384
293
|
url: method_url,
|
@@ -467,7 +376,6 @@ module IBMWatson
|
|
467
376
|
|
468
377
|
method_url = "/v3/classifiers/%s" % [ERB::Util.url_encode(classifier_id)]
|
469
378
|
|
470
|
-
headers = authenticator.authenticate(headers)
|
471
379
|
response = request(
|
472
380
|
method: "POST",
|
473
381
|
url: method_url,
|
@@ -498,7 +406,6 @@ module IBMWatson
|
|
498
406
|
|
499
407
|
method_url = "/v3/classifiers/%s" % [ERB::Util.url_encode(classifier_id)]
|
500
408
|
|
501
|
-
headers = authenticator.authenticate(headers)
|
502
409
|
request(
|
503
410
|
method: "DELETE",
|
504
411
|
url: method_url,
|
@@ -533,7 +440,6 @@ module IBMWatson
|
|
533
440
|
|
534
441
|
method_url = "/v3/classifiers/%s/core_ml_model" % [ERB::Util.url_encode(classifier_id)]
|
535
442
|
|
536
|
-
headers = authenticator.authenticate(headers)
|
537
443
|
response = request(
|
538
444
|
method: "GET",
|
539
445
|
url: method_url,
|
@@ -574,7 +480,6 @@ module IBMWatson
|
|
574
480
|
|
575
481
|
method_url = "/v3/user_data"
|
576
482
|
|
577
|
-
headers = authenticator.authenticate(headers)
|
578
483
|
request(
|
579
484
|
method: "DELETE",
|
580
485
|
url: method_url,
|
@@ -11,14 +11,14 @@ TEN_MILLISECONDS = 0.01
|
|
11
11
|
|
12
12
|
# Class for interacting with the WebSocket API
|
13
13
|
class WebSocketClient
|
14
|
-
def initialize(audio: nil, chunk_data:, options:, recognize_callback:,
|
14
|
+
def initialize(audio: nil, chunk_data:, options:, recognize_callback:, service_url:, headers:, disable_ssl_verification: false)
|
15
15
|
@audio = audio
|
16
16
|
@options = options
|
17
17
|
@callback = recognize_callback
|
18
18
|
@bytes_sent = 0
|
19
19
|
@headers = headers
|
20
20
|
@is_listening = false
|
21
|
-
@
|
21
|
+
@service_url = service_url
|
22
22
|
@timer = nil
|
23
23
|
@chunk_data = chunk_data
|
24
24
|
@mic_running = false
|
@@ -79,10 +79,10 @@ class WebSocketClient
|
|
79
79
|
EM&.reactor_thread&.join
|
80
80
|
EM.run do
|
81
81
|
if @disable_ssl_verification
|
82
|
-
@
|
83
|
-
@client = Faye::WebSocket::Client.new(@
|
82
|
+
@service_url = @service_url.sub("wss:", "ws:")
|
83
|
+
@client = Faye::WebSocket::Client.new(@service_url, nil, tls: { verify_peer: false, fail_if_no_peer_cert: false }, headers: @headers)
|
84
84
|
else
|
85
|
-
@client = Faye::WebSocket::Client.new(@
|
85
|
+
@client = Faye::WebSocket::Client.new(@service_url, nil, headers: @headers)
|
86
86
|
end
|
87
87
|
@client.onclose = on_close
|
88
88
|
@client.onerror = on_error
|
data/lib/ibm_watson.rb
CHANGED
@@ -7,6 +7,15 @@ module IBMWatson
|
|
7
7
|
ApiException = IBMCloudSdkCore::ApiException
|
8
8
|
DetailedResponse = IBMCloudSdkCore::DetailedResponse
|
9
9
|
|
10
|
+
module Authenticators
|
11
|
+
BasicAuthenticator = IBMCloudSdkCore::BasicAuthenticator
|
12
|
+
BearerTokenAuthenticator = IBMCloudSdkCore::BearerTokenAuthenticator
|
13
|
+
CloudPakForDataAuthenticator = IBMCloudSdkCore::CloudPakForDataAuthenticator
|
14
|
+
ConfigBasedAuthenticatorFactory = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory
|
15
|
+
IamAuthenticator = IBMCloudSdkCore::IamAuthenticator
|
16
|
+
NoAuthAuthenticator = IBMCloudSdkCore::NoAuthAuthenticator
|
17
|
+
end
|
18
|
+
|
10
19
|
require_relative("./ibm_watson/personality_insights_v3.rb")
|
11
20
|
require_relative("./ibm_watson/tone_analyzer_v3.rb")
|
12
21
|
require_relative("./ibm_watson/assistant_v1.rb")
|
@@ -11,7 +11,7 @@ if !ENV["ASSISTANT_APIKEY"].nil? && !ENV["ASSISTANT_URL"].nil?
|
|
11
11
|
include Minitest::Hooks
|
12
12
|
attr_accessor :service
|
13
13
|
def before_all
|
14
|
-
authenticator =
|
14
|
+
authenticator = IBMWatson::Authenticators::IamAuthenticator.new(
|
15
15
|
apikey: ENV["ASSISTANT_APIKEY"],
|
16
16
|
version: "2018-02-16"
|
17
17
|
)
|
@@ -11,7 +11,7 @@ if !ENV["ASSISTANT_APIKEY"].nil? && !ENV["ASSISTANT_URL"].nil?
|
|
11
11
|
include Minitest::Hooks
|
12
12
|
attr_accessor :service
|
13
13
|
def before_all
|
14
|
-
authenticator =
|
14
|
+
authenticator = IBMWatson::Authenticators::IamAuthenticator.new(
|
15
15
|
apikey: ENV["ASSISTANT_APIKEY"]
|
16
16
|
)
|
17
17
|
@service = IBMWatson::AssistantV2.new(
|
@@ -11,7 +11,7 @@ if !ENV["COMPARE_COMPLY_APIKEY"].nil?
|
|
11
11
|
attr_accessor :service, :environment_id, :collection_id
|
12
12
|
|
13
13
|
def before_all
|
14
|
-
authenticator =
|
14
|
+
authenticator = IBMWatson::Authenticators::IamAuthenticator.new(
|
15
15
|
apikey: ENV["ASSISTANT_APIKEY"]
|
16
16
|
)
|
17
17
|
@service = IBMWatson::CompareComplyV1.new(
|
@@ -10,7 +10,7 @@ if !ENV["DISCOVERY_APIKEY"].nil? && !ENV["DISCOVERY_URL"].nil?
|
|
10
10
|
attr_accessor :service, :environment_id, :collection_id
|
11
11
|
|
12
12
|
def before_all
|
13
|
-
authenticator =
|
13
|
+
authenticator = IBMWatson::Authenticators::IamAuthenticator.new(
|
14
14
|
apikey: ENV["DISCOVERY_APIKEY"]
|
15
15
|
)
|
16
16
|
@service = IBMWatson::DiscoveryV1.new(
|
@@ -203,9 +203,6 @@ if !ENV["DISCOVERY_APIKEY"].nil? && !ENV["DISCOVERY_URL"].nil?
|
|
203
203
|
assert_equal("deleted", delete_doc["status"])
|
204
204
|
end
|
205
205
|
|
206
|
-
# def test_queries
|
207
|
-
# end
|
208
|
-
|
209
206
|
def test_list_credentials
|
210
207
|
credentials = @service.list_credentials(
|
211
208
|
environment_id: @environment_id
|
@@ -10,7 +10,7 @@ if !ENV["LANGUAGE_TRANSLATOR_APIKEY"].nil? && !ENV["LANGUAGE_TRANSLATOR_URL"].ni
|
|
10
10
|
include Minitest::Hooks
|
11
11
|
attr_accessor :service
|
12
12
|
def before_all
|
13
|
-
authenticator =
|
13
|
+
authenticator = IBMWatson::Authenticators::IamAuthenticator.new(
|
14
14
|
apikey: ENV["LANGUAGE_TRANSLATOR_APIKEY"]
|
15
15
|
)
|
16
16
|
@service = IBMWatson::LanguageTranslatorV3.new(
|
@@ -10,7 +10,7 @@ if !ENV["NATURAL_LANGUAGE_CLASSIFIER_APIKEY"].nil? && !ENV["NATURAL_LANGUAGE_CLA
|
|
10
10
|
include Minitest::Hooks
|
11
11
|
attr_accessor :service
|
12
12
|
def before_all
|
13
|
-
authenticator =
|
13
|
+
authenticator = IBMWatson::Authenticators::IamAuthenticator.new(
|
14
14
|
apikey: ENV["NATURAL_LANGUAGE_CLASSIFIER_APIKEY"]
|
15
15
|
)
|
16
16
|
@service = IBMWatson::NaturalLanguageClassifierV1.new(
|
@@ -9,7 +9,7 @@ if !ENV["NATURAL_LANGUAGE_UNDERSTANDING_APIKEY"].nil? && !ENV["NATURAL_LANGUAGE_
|
|
9
9
|
include Minitest::Hooks
|
10
10
|
attr_accessor :service
|
11
11
|
def before_all
|
12
|
-
authenticator =
|
12
|
+
authenticator = IBMWatson::Authenticators::IamAuthenticator.new(
|
13
13
|
apikey: ENV["NATURAL_LANGUAGE_UNDERSTANDING_APIKEY"]
|
14
14
|
)
|
15
15
|
@service = IBMWatson::NaturalLanguageUnderstandingV1.new(
|
@@ -9,7 +9,7 @@ if !ENV["PERSONALITY_INSIGHTS_APIKEY"].nil? && !ENV["PERSONALITY_INSIGHTS_URL"].
|
|
9
9
|
include Minitest::Hooks
|
10
10
|
attr_accessor :service
|
11
11
|
def before_all
|
12
|
-
authenticator =
|
12
|
+
authenticator = IBMWatson::Authenticators::IamAuthenticator.new(
|
13
13
|
apikey: ENV["PERSONALITY_INSIGHTS_APIKEY"]
|
14
14
|
)
|
15
15
|
@service = IBMWatson::PersonalityInsightsV3.new(
|
@@ -28,7 +28,7 @@ if !ENV["SPEECH_TO_TEXT_APIKEY"].nil? && !ENV["SPEECH_TO_TEXT_URL"].nil?
|
|
28
28
|
include Minitest::Hooks
|
29
29
|
attr_accessor :service
|
30
30
|
def before_all
|
31
|
-
authenticator =
|
31
|
+
authenticator = IBMWatson::Authenticators::IamAuthenticator.new(
|
32
32
|
apikey: ENV["SPEECH_TO_TEXT_APIKEY"]
|
33
33
|
)
|
34
34
|
@service = IBMWatson::SpeechToTextV1.new(
|
@@ -246,7 +246,7 @@ if !ENV["SPEECH_TO_TEXT_APIKEY"].nil? && !ENV["SPEECH_TO_TEXT_URL"].nil?
|
|
246
246
|
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
|
247
247
|
atomic_boolean = Concurrent::AtomicBoolean.new
|
248
248
|
mycallback = MyRecognizeCallback.new(atomic_boolean: atomic_boolean)
|
249
|
-
authenticator =
|
249
|
+
authenticator = IBMWatson::Authenticators::BearerTokenAuthenticator.new(
|
250
250
|
bearer_token: "bogus_iam_access_token"
|
251
251
|
)
|
252
252
|
temp_service = IBMWatson::SpeechToTextV1.new(
|
@@ -9,7 +9,7 @@ if !ENV["TEXT_TO_SPEECH_APIKEY"].nil? && !ENV["TEXT_TO_SPEECH_URL"].nil?
|
|
9
9
|
include Minitest::Hooks
|
10
10
|
attr_accessor :service
|
11
11
|
def before_all
|
12
|
-
authenticator =
|
12
|
+
authenticator = IBMWatson::Authenticators::IamAuthenticator.new(
|
13
13
|
apikey: ENV["TEXT_TO_SPEECH_APIKEY"]
|
14
14
|
)
|
15
15
|
@service = IBMWatson::TextToSpeechV1.new(
|
@@ -9,7 +9,7 @@ if !ENV["TONE_ANALYZER_APIKEY"].nil? && !ENV["TONE_ANALYZER_URL"].nil?
|
|
9
9
|
include Minitest::Hooks
|
10
10
|
attr_accessor :service
|
11
11
|
def before_all
|
12
|
-
authenticator =
|
12
|
+
authenticator = IBMWatson::Authenticators::IamAuthenticator.new(
|
13
13
|
apikey: ENV["TONE_ANALYZER_APIKEY"]
|
14
14
|
)
|
15
15
|
@service = IBMWatson::ToneAnalyzerV3.new(
|
@@ -10,7 +10,7 @@ if !ENV["VISUAL_RECOGNITION_APIKEY"].nil? && !ENV["VISUAL_RECOGNITION_URL"].nil?
|
|
10
10
|
include Minitest::Hooks
|
11
11
|
attr_accessor :service, :classifier_id
|
12
12
|
def before_all
|
13
|
-
authenticator =
|
13
|
+
authenticator = IBMWatson::Authenticators::IamAuthenticator.new(
|
14
14
|
apikey: ENV["VISUAL_RECOGNITION_APIKEY"]
|
15
15
|
)
|
16
16
|
@service = IBMWatson::VisualRecognitionV3.new(
|
@@ -37,13 +37,6 @@ if !ENV["VISUAL_RECOGNITION_APIKEY"].nil? && !ENV["VISUAL_RECOGNITION_URL"].nil?
|
|
37
37
|
refute(dog_results.nil?)
|
38
38
|
end
|
39
39
|
|
40
|
-
def test_detect_faces
|
41
|
-
output = @service.detect_faces(
|
42
|
-
url: "https://www.ibm.com/ibm/ginni/images/ginni_bio_780x981_v4_03162016.jpg"
|
43
|
-
).result
|
44
|
-
refute(output.nil?)
|
45
|
-
end
|
46
|
-
|
47
40
|
def test_custom_classifier
|
48
41
|
skip "Time Consuming"
|
49
42
|
cars = File.open(Dir.getwd + "/resources/cars.zip")
|