watson_developer_cloud.visual_recognition_v3 module

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

class Class(class_name)[source]

Bases: object

A category within a classifier.

Attr str class_name

The name of the class.

class ClassResult(class_name, score, type_hierarchy=None)[source]

Bases: object

Result of a class within a classifier.

Attr str class_name

Name of the class.

Class names are translated in the language defined by the Accept-Language request header for the build-in classifier IDs (default, food, and explicit). Class names of custom classifiers are not translated. The response might not be in the specified language when the requested language is not supported or when there is no translation for the class name. :attr float score: Confidence score for the property in the range of 0 to 1. A higher score indicates greater likelihood that the class is depicted in the image. The default threshold for returning scores from a classifier is 0.5. :attr str type_hierarchy: (optional) Knowledge graph of the property. For example, /fruit/pome/apple/eating apple/Granny Smith. Included only if identified.

class ClassifiedImage(classifiers, source_url=None, resolved_url=None, image=None, error=None)[source]

Bases: object

Results for one image.

Attr str source_url

(optional) Source of the image before any redirects. Not

returned when the image is uploaded. :attr str resolved_url: (optional) Fully resolved URL of the image after redirects are followed. Not returned when the image is uploaded. :attr str image: (optional) Relative path of the image file if uploaded directly. Not returned when the image is passed by URL. :attr ErrorInfo error: (optional) Information about what might have caused a failure, such as an image that is too large. Not returned when there is no error. :attr list[ClassifierResult] classifiers: The classifiers.

class ClassifiedImages(images, custom_classes=None, images_processed=None, warnings=None)[source]

Bases: object

Results for all images.

Attr int custom_classes

(optional) Number of custom classes identified in the

images. :attr int images_processed: (optional) Number of images processed for the API call. :attr list[ClassifiedImage] images: Classified images. :attr list[WarningInfo] warnings: (optional) Information about what might cause less than optimal output. For example, a request sent with a corrupt .zip file and a list of image URLs will still complete, but does not return the expected output. Not returned when there is no warning.

class Classifier(classifier_id, name, owner=None, status=None, core_ml_enabled=None, explanation=None, created=None, classes=None, retrained=None, updated=None)[source]

Bases: object

Information about a classifier.

Attr str classifier_id

ID of a classifier identified in the image.

Attr str name

Name of the classifier.

Attr str owner

(optional) Unique ID of the account who owns the classifier. Might

not be returned by some requests. :attr str status: (optional) Training status of classifier. :attr bool core_ml_enabled: (optional) Whether the classifier can be downloaded as a Core ML model after the training status is ready. :attr str explanation: (optional) If classifier training has failed, this field might explain why. :attr datetime created: (optional) Date and time in Coordinated Universal Time (UTC) that the classifier was created. :attr list[Class] classes: (optional) Classes that define a classifier. :attr datetime retrained: (optional) Date and time in Coordinated Universal Time (UTC) that the classifier was updated. Might not be returned by some requests. Identical to updated and retained for backward compatibility. :attr datetime updated: (optional) Date and time in Coordinated Universal Time (UTC) that the classifier was most recently updated. The field matches either retrained or created. Might not be returned by some requests.

class ClassifierResult(name, classifier_id, classes)[source]

Bases: object

Classifier and score combination.

Attr str name

Name of the classifier.

Attr str classifier_id

ID of a classifier identified in the image.

Attr list[ClassResult] classes

Classes within the classifier.

class Classifiers(classifiers)[source]

Bases: object

A container for the list of classifiers.

Attr list[Classifier] classifiers

List of classifiers.

class DetectedFaces(images_processed, images, warnings=None)[source]

Bases: object

Results for all faces.

Attr int images_processed

Number of images processed for the API call.

Attr list[ImageWithFaces] images

The images.

Attr list[WarningInfo] warnings

(optional) Information about what might cause less

than optimal output. For example, a request sent with a corrupt .zip file and a list of image URLs will still complete, but does not return the expected output. Not returned when there is no warning.

class ErrorInfo(code, description, error_id)[source]

Bases: object

Information about what might have caused a failure, such as an image that is too large. Not returned when there is no error.

Attr int code

HTTP status code.

Attr str description

Human-readable error description. For example, `File size limit

exceeded`. :attr str error_id: Codified error string. For example, limit_exceeded.

class Face(age=None, gender=None, face_location=None)[source]

Bases: object

Information about the face.

Attr FaceAge age

(optional) Age information about a face.

Attr FaceGender gender

(optional) Information about the gender of the face.

Attr FaceLocation face_location

(optional) The location of the bounding box around

the face.

class FaceAge(score, min=None, max=None)[source]

Bases: object

Age information about a face.

Attr int min

(optional) Estimated minimum age.

Attr int max

(optional) Estimated maximum age.

Attr float score

Confidence score in the range of 0 to 1. A higher score indicates

greater confidence in the estimated value for the property.

class FaceGender(gender, gender_label, score)[source]

Bases: object

Information about the gender of the face.

Attr str gender

Gender identified by the face. For example, MALE or FEMALE.

Attr str gender_label

The word for “male” or “female” in the language defined by the

Accept-Language request header. :attr float score: Confidence score in the range of 0 to 1. A higher score indicates greater confidence in the estimated value for the property.

class FaceLocation(width, height, left, top)[source]

Bases: object

The location of the bounding box around the face.

Attr float width

Width in pixels of face region.

Attr float height

Height in pixels of face region.

Attr float left

X-position of top-left pixel of face region.

Attr float top

Y-position of top-left pixel of face region.

class ImageWithFaces(faces, image=None, source_url=None, resolved_url=None, error=None)[source]

Bases: object

Information about faces in the image.

Attr list[Face] faces

Faces detected in the images.

Attr str image

(optional) Relative path of the image file if uploaded directly. Not

returned when the image is passed by URL. :attr str source_url: (optional) Source of the image before any redirects. Not returned when the image is uploaded. :attr str resolved_url: (optional) Fully resolved URL of the image after redirects are followed. Not returned when the image is uploaded. :attr ErrorInfo error: (optional) Information about what might have caused a failure, such as an image that is too large. Not returned when there is no error.

class WarningInfo(warning_id, description)[source]

Bases: object

Information about something that went wrong.

Attr str warning_id

Codified warning string, such as limit_reached.

Attr str description

Information about the error.