Options
All
  • Public
  • Public/Protected
  • All
Menu

Class VisualRecognitionV3

IBM Watson™ Visual Recognition is discontinued. Existing instances are supported until 1 December 2021, but as of 7 January 2021, you can't create instances. Any instance that is provisioned on 1 December 2021 will be deleted. {: deprecated} interfaces

The IBM Watson Visual Recognition service uses deep learning algorithms to identify scenes and objects in images that you upload to the service. You can create and train a custom classifier to identify subjects that suit your needs.

API Version: 3.0 See: https://cloud.ibm.com/docs/visual-recognition

Hierarchy

  • BaseService
    • VisualRecognitionV3

Index

Constructors

constructor

  • Construct a VisualRecognitionV3 object.

    Parameters

    Name Type Attribute Description
    options UserOptions

    Options for the service.

    Returns VisualRecognitionV3

Properties

version

version: string

Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2018-03-19.

Static DEFAULT_SERVICE_NAME

DEFAULT_SERVICE_NAME: string = "watson_vision_combined"

Static DEFAULT_SERVICE_URL

DEFAULT_SERVICE_URL: string = "https://api.us-south.visual-recognition.watson.cloud.ibm.com"

Methods

classify

  • Classify images.

    Classify images with built-in or custom classifiers.

    Parameters

    Name Type Attribute Description
    params ClassifyParams Optional

    Properties

    Name Type Attributes Description
    acceptLanguage AcceptLanguage | string Optional The desired language of parts of the response. See the response for details.
    classifierIds string[] Optional Which classifiers to apply. Overrides the **owners** parameter. You can specify both custom and built-in classifier IDs. The built-in `default` classifier is used if both **classifier_ids** and **owners** parameters are empty.
    headers OutgoingHttpHeaders Optional
    imagesFile ReadableStream | Buffer Optional An image file (.gif, .jpg, .png, .tif) or .zip file with images. Maximum image size is 10 MB. Include no more than 20 images and limit the .zip file to 100 MB. Encode the image and .zip file names in UTF-8 if they contain non-ASCII characters. The service assumes UTF-8 encoding if it encounters non-ASCII characters.
    imagesFileContentType string Optional The content type of imagesFile.
    imagesFilename string Optional The filename for imagesFile.
    owners string[] Optional The categories of classifiers to apply. The **classifier_ids** parameter overrides **owners**, so make sure that **classifier_ids** is empty. - Use `IBM` to classify against the `default` general classifier. You get the same result if both **classifier_ids** and **owners** parameters are empty. - Use `me` to classify against all your custom classifiers. However, for better performance use **classifier_ids** to specify the specific custom classifiers to apply. - Use both `IBM` and `me` to analyze the image against both classifier categories.
    threshold number Optional The minimum score a class must have to be displayed in the response. Set the threshold to `0.0` to return all identified classes.
    url string Optional The URL of an image (.gif, .jpg, .png, .tif) to analyze. The minimum recommended pixel density is 32X32 pixels, but the service tends to perform better with images that are at least 224 x 224 pixels. The maximum image size is 10 MB.

    Returns Promise<Response<ClassifiedImages>>

createClassifier

  • Create a classifier.

    Train a new multi-faceted classifier on the uploaded image data. Create your custom classifier with positive or negative example training images. Include at least two sets of examples, either two positive example files or one positive and one negative file. You can upload a maximum of 256 MB per call.

    Tips when creating:

    • If you set the X-Watson-Learning-Opt-Out header parameter to true when you create a classifier, the example training images are not stored. Save your training images locally. For more information, see [Data collection](#data-collection).

    • Encode all names in UTF-8 if they contain non-ASCII characters (.zip and image file names, and classifier and class names). The service assumes UTF-8 encoding if it encounters non-ASCII characters.

    Parameters

    Name Type Attribute Description
    params CreateClassifierParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    name string The name of the new classifier. Encode special characters in UTF-8.
    positiveExamples Record<string, ReadableStream | Buffer> A dictionary that contains the value for each classname. The value is a .zip file of images that depict the visual subject of a class in the new classifier. You can include more than one positive example file in a call.
    headers OutgoingHttpHeaders Optional
    negativeExamples ReadableStream | Buffer Optional A .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.
    negativeExamplesFilename string Optional The filename for negativeExamples.

    Returns Promise<Response<Classifier>>

deleteClassifier

  • Delete a classifier.

    Parameters

    Name Type Attribute Description
    params DeleteClassifierParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    classifierId string The ID of the classifier.
    headers OutgoingHttpHeaders Optional

    Returns Promise<Response<Empty>>

deleteUserData

  • Delete labeled data.

    Deletes all data associated with a specified customer ID. The method has no effect if no data is associated with the customer ID.

    You associate a customer ID with data by passing the X-Watson-Metadata header with a request that passes data. For more information about personal data and customer IDs, see Information security.

    Parameters

    Name Type Attribute Description
    params DeleteUserDataParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    customerId string The customer ID for which all data is to be deleted.
    headers OutgoingHttpHeaders Optional

    Returns Promise<Response<Empty>>

disableRetries

  • disableRetries(): void
  • Disables retries.

    Returns void

enableRetries

  • enableRetries(retryOptions?: RetryOptions): void
  • Enable retries for unfulfilled requests.

    Parameters

    Name Type Attribute Description
    retryOptions RetryOptions Optional

    configuration for retries

    Returns void

getAuthenticator

  • getAuthenticator(): any
  • Get the instance of the authenticator set on the service.

    Returns any

getClassifier

  • Retrieve classifier details.

    Retrieve information about a custom classifier.

    Parameters

    Name Type Attribute Description
    params GetClassifierParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    classifierId string The ID of the classifier.
    headers OutgoingHttpHeaders Optional

    Returns Promise<Response<Classifier>>

getCoreMlModel

  • Retrieve a Core ML model of a classifier.

    Download a Core ML model file (.mlmodel) of a custom classifier that returns "core_ml_enabled": true in the classifier details.

    Parameters

    Name Type Attribute Description
    params GetCoreMlModelParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    classifierId string The ID of the classifier.
    headers OutgoingHttpHeaders Optional

    Returns Promise<Response<ReadableStream>>

getHttpClient

  • getHttpClient(): AxiosInstance
  • Get the Axios instance set on the service. All requests will be made using this instance.

    Returns AxiosInstance

listClassifiers

  • Retrieve a list of classifiers.

    Parameters

    Name Type Attribute Description
    params ListClassifiersParams Optional

    Properties

    Name Type Attributes Description
    headers OutgoingHttpHeaders Optional
    verbose boolean Optional Specify `true` to return details about the classifiers. Omit this parameter to return a brief list of classifiers.

    Returns Promise<Response<Classifiers>>

setEnableGzipCompression

  • setEnableGzipCompression(setting: boolean): void
  • Turn request body compression on or off.

    Parameters

    Name Type Attribute Description
    setting boolean

    Will turn it on if 'true', off if 'false'.

    Returns void

setServiceUrl

  • setServiceUrl(url: string): void
  • Set the service URL to send requests to.

    Parameters

    Name Type Attribute Description
    url string

    The base URL for the service.

    Returns void

updateClassifier

  • Update a classifier.

    Update a custom classifier by adding new positive or negative classes or by adding new images to existing classes. You must supply at least one set of positive or negative examples. For details, see Updating custom classifiers.

    Encode all names in UTF-8 if they contain non-ASCII characters (.zip and image file names, and classifier and class names). The service assumes UTF-8 encoding if it encounters non-ASCII characters.

    Tips about retraining:

    • You can't update the classifier if the X-Watson-Learning-Opt-Out header parameter was set to true when the classifier was created. Training images are not stored in that case. Instead, create another classifier. For more information, see Data collection.

    • Don't make retraining calls on a classifier until the status is ready. When you submit retraining requests in parallel, the last request overwrites the previous requests. The retrained property shows the last time the classifier retraining finished.

    Parameters

    Name Type Attribute Description
    params UpdateClassifierParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    classifierId string The ID of the classifier.
    headers OutgoingHttpHeaders Optional
    negativeExamples ReadableStream | Buffer Optional A .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.
    negativeExamplesFilename string Optional The filename for negativeExamples.
    positiveExamples Record<string, ReadableStream | Buffer> Optional A dictionary that contains the value for each classname. The value is a .zip file of images that depict the visual subject of a class in the classifier. The positive examples create or update classes in the classifier. You can include more than one positive example file in a call.

    Returns Promise<Response<Classifier>>

Generated using TypeDoc