new VisualRecognitionV3(options)
Parameters:
| Name |
Type |
Description |
options |
|
|
- Source:
Methods
classify(params, callback) → {ReadableStream|undefined}
Accepts either a url, a single image file, or a zip file with multiple
images (.jpeg, .png, .gif) and scores every available classifier
on each image. It then applies a threshold and returns the list
of relevant classifier scores for each image.
Parameters:
| Name |
Type |
Description |
params |
Object
|
Properties
| Name |
Type |
Attributes |
Default |
Description |
images_file |
ReadStream
|
<optional>
|
|
The image file (.jpg, .png, .gif) or compressed (.zip) file of images to classify. The total number of images is limited to 100. Either images_file or url must be specified. |
url |
String
|
<optional>
|
|
The URL of an image (.jpg, .png, .gif). Redirects are followed, so you can use shortened URLs. The resolved URL is returned in the response. Either images_file or url must be specified. |
classifier_ids |
Array
|
<optional>
|
['default']
|
An array of classifier IDs to classify the images against. |
owners |
Array
|
<optional>
|
['me','IBM']
|
An array with the value(s) "IBM" and/or "me" to specify which classifiers to run. |
threshold |
Number
|
<optional>
|
|
A floating point value that specifies the minimum score a class must have to be displayed in the response. |
|
callback |
function
|
|
- Source:
Returns:
-
Type
-
ReadableStream
|
undefined
Example
* {
"images": [{
"classifiers": [{
"classes": [{
"class": "animal",
"score": 0.998771,
"type_hierarchy": "/animals"
}, {
"class": "mammal",
"score": 0.998499,
"type_hierarchy": "/animals/mammal"
}, {
"class": "dog",
"score": 0.900249,
"type_hierarchy": "/animals/pets/dog"
}, {
"class": "puppy",
"score": 0.5,
"type_hierarchy": "/animals/pets/puppy"
}],
"classifier_id": "default",
"name": "default"
}],
"image": "dog.jpg"
}],
"images_processed": 1
}
createClassifier(params) → {ReadableStream|undefined}
Train a new classifier from example images which are uploaded.
This call returns before training has completed. You'll need to use the
getClassifer method to make sure the classifier has completed training and
was successful before you can classify any images with the newly created
classifier.
Parameters:
| Name |
Type |
Description |
params |
Object
|
Properties
| Name |
Type |
Attributes |
Description |
name |
String
|
|
The desired short name of the new classifier. |
classname_positive_examples |
ReadStream
|
|
_positive_examples One or more compressed (.zip) files of images that depict the visual subject for a class within the new classifier. Must contain a minimum of 10 images. You may supply multiple files with different class names in the key. |
negative_examples |
ReadStream
|
<optional>
|
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. Required if only one positive set is provided. |
|
- Source:
Returns:
-
Type
-
ReadableStream
|
undefined
Examples
{
foo_positive_examples: fs.createReadStream('./foo-pics.zip'),
negative_examples: fs.createReadStream('./not-foo-pics.zip'),
name: 'to-foo-or-not'
}
{
foo_positive_examples: fs.createReadStream('./foo-pics.zip'),
bar_positive_examples: fs.createReadStream('./bar-pics.zip'),
name: 'foo-vs-bar'
}
{
foo_positive_examples: fs.createReadStream('./foo-pics.zip'),
bar_positive_examples: fs.createReadStream('./bar-pics.zip'),
negative_examples: fs.createReadStream('./not-foo-pics.zip'),
name: 'foo-bar-not'
}
{
"classifier_id": "fruit_679357912",
"name": "fruit",
"owner": "a3a48ea7-492b-448b-87d7-9dade8bde5a9",
"status": "training",
"created": "2016-05-23T21:50:41.680Z",
"classes": [{
"class": "banana"
}, {
"class": "apple"
}]
}
deleteClassifier(params, callback) → {ReadableStream|undefined}
Deletes a custom classifier with the specified classifier id.
Parameters:
| Name |
Type |
Description |
params |
Object
|
Properties
| Name |
Type |
Description |
classifier_id |
String
|
The classifier id |
|
callback |
function
|
|
- Source:
Returns:
-
Type
-
ReadableStream
|
undefined
detectFaces(params, callback) → {ReadableStream|undefined}
Accepts either a url, a single image file, or a zip file with multiple
images (.jpeg, .png, .gif) and attempts to extract faces and
identities. It then applies a threshold
and returns the list of relevant identities, locations, and metadata
for found faces for each image.
Parameters:
| Name |
Type |
Description |
params |
Object
|
Properties
| Name |
Type |
Attributes |
Description |
images_file |
ReadStream
|
<optional>
|
The image file (.jpg, .png, .gif) or compressed (.zip) file of images to classify. The total number of images is limited to 100. Either images_file or url must be specified. |
url |
String
|
<optional>
|
The URL of an image (.jpg, .png, .gif). Redirects are followed, so you can use shortened URLs. The resolved URL is returned in the response. Either images_file or url must be specified. |
|
callback |
function
|
|
- Source:
Returns:
-
Type
-
ReadableStream
|
undefined
Example
{
"images": [{
"faces": [{
"age": {
"max": 54,
"min": 45,
"score": 0.40459
},
"face_location": {
"height": 131,
"left": 80,
"top": 68,
"width": 123
},
"gender": {
"gender": "MALE",
"score": 0.993307
},
"identity": {
"name": "Barack Obama",
"score": 0.970688,
"type_hierarchy": "/people/politicians/democrats/barack obama"
}
}],
"image": "obama.jpg"
}],
"images_processed": 1
}
getClassifier(params, callback) → {ReadableStream|undefined}
Retrieves information about a specific classifier.
Parameters:
| Name |
Type |
Description |
params |
Object
|
Properties
| Name |
Type |
Description |
classifier_id |
Boolean
|
The classifier id |
|
callback |
function
|
|
- Source:
Returns:
-
Type
-
ReadableStream
|
undefined
Example
{
"classifier_id": "fruit_679357912",
"name": "fruit",
"owner": "a3a42ea7-492b-448b-87d7-9dfde8bde519 ",
"status": "ready",
"created": "2016-05-23T21:50:41.680Z",
"classes": [{
"class": "banana"
}, {
"class": "apple"
}]
}
getCredentialsFromBluemix() → {*}
Bluemix uses a different naming convention for VR v3 than for other services
- Source:
Returns:
-
Type
-
*
getCredentialsFromEnvironment() → {Object}
Pulls api_key from VISUAL_RECOGNITION_API_KEY env property
- Source:
Returns:
-
Type
-
Object
listClassifiers(params, callback) → {ReadableStream|undefined}
Retrieve a list of all classifiers, including built-in and
user-created classifiers.
Parameters:
| Name |
Type |
Description |
params |
Object
|
Properties
| Name |
Type |
Attributes |
Default |
Description |
verbose |
Boolean
|
<optional>
|
false
|
|
|
callback |
function
|
|
- Source:
Returns:
-
Type
-
ReadableStream
|
undefined
Example
{
"classifiers": [{
"classifier_id": "fruit_679357912",
"name": "fruit",
"status": "ready"
}, {
"classifier_id": "Dogs_2017013066",
"name": "Dogs",
"status": "ready"
}]
}
recognizeText(params, callback) → {ReadableStream|undefined}
Accepts either a url, single image file, or a zip file with multiple
images (.jpeg, .png, .gif) and attempts to recognize text
found in the image. It then applies a threshold
and returns the list of relevant locations, strings, and metadata
for discovered text in each image.
Parameters:
| Name |
Type |
Description |
params |
Object
|
Properties
| Name |
Type |
Attributes |
Description |
images_file |
ReadStream
|
<optional>
|
The image file (.jpg, .png, .gif) or compressed (.zip) file of images to classify. The total number of images is limited to 100. Either images_file or url must be specified. |
url |
String
|
<optional>
|
The URL of an image (.jpg, .png, .gif). Redirects are followed, so you can use shortened URLs. The resolved URL is returned in the response. Either images_file or url must be specified. |
|
callback |
function
|
|
- Source:
Returns:
-
Type
-
ReadableStream
|
undefined
Example
{
"images": [{
"image": "car.png",
"text": "3 jag [brio]",
"words": [{
"line_number": 0,
"location": {
"height": 53,
"left": 204,
"top": 294,
"width": 27
},
"score": 0.50612,
"word": "3"
}, {
"line_number": 0,
"location": {
"height": 32,
"left": 264,
"top": 288,
"width": 56
},
"score": 0.958628,
"word": "jag"
}, {
"line_number": 0,
"location": {
"height": 40,
"left": 324,
"top": 288,
"width": 92
},
"score": 0.00165806,
"word": "brio"
}]
}],
"images_processed": 1
}