watson.visual_recognition({version: 'v3', ...});
Parameters:
| Name |
Type |
Description |
options |
|
|
- Source:
Methods
classify(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.
Example response:
{
"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
}
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
params.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. |
params.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. |
params.classifier_ids |
Array
|
<optional>
|
['default']
|
An array of classifier IDs to classify the images against. |
params.owners |
Array
|
<optional>
|
['me','IBM']
|
An array with the value(s) "IBM" and/or "me" to specify which classifiers to run. |
params.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
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.
Example inputs:
{
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'
}
Example output:
{
"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"}
]
}
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
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(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.
Example output:
{
"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
}
Parameters:
| Name |
Type |
Attributes |
Description |
params.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. |
params.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
getClassifier(params, callback) → {ReadableStream|undefined}
Retrieves information about a specific classifier.
Example output:
{
classifier_id: 'fruit_679357912',
name: 'fruit',
owner: 'a3a48ea7-492b-448b-87d7-9dade8bde5a9',
status: 'ready',
created: '2016-05-23T21:50:41.680Z',
classes: [
{ class: 'banana' },
{ class: 'apple' }
]
}
Parameters:
| Name |
Type |
Description |
params |
Object
|
Properties
| Name |
Type |
Description |
classifier_id |
Boolean
|
The classifier id |
|
callback |
function
|
|
- Source:
Returns:
-
Type
-
ReadableStream
|
undefined
listClassifiers(params, callback) → {ReadableStream|undefined}
Retrieve a list of all classifiers, including built-in and
user-created classifiers.
Example output:
{"classifiers": [
{
"classifier_id": "fruit_679357912",
"name": "fruit",
"status": "ready"
},
{
"classifier_id": "Dogs_2017013066",
"name": "Dogs",
"status": "ready"
}
]}
Parameters:
| Name |
Type |
Description |
params |
Object
|
Properties
| Name |
Type |
Attributes |
Default |
Description |
verbose |
Boolean
|
<optional>
|
false
|
|
|
callback |
function
|
|
- Source:
Returns:
-
Type
-
ReadableStream
|
undefined
recognizeText(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.
Example output:
{
"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
}
Parameters:
| Name |
Type |
Attributes |
Description |
params.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. |
params.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