watson_developer_cloud.visual_recognition_v3_adapter module

class VisualRecognitionV3Adapter(version, url='https://gateway.watsonplatform.net/visual-recognition/api', api_key=None, iam_apikey=None, iam_access_token=None, iam_url=None)[source]

Bases: watson_developer_cloud.visual_recognition_v3.VisualRecognitionV3

create_classifier(name, **kwargs)[source]

Create a classifier. :param str name: The name of the new classifier. Encode special characters in UTF-8. :param file <NAME>_positive_examples: A compressed (.zip) file of images that depict the visual subject for a class within the new classifier. Include at least 10 images in .jpg or .png format. The minimum recommended image resolution is 32X32 pixels. The maximum number of images is 10,000 images or 100 MB per .zip file. Encode special characters in the file name in UTF-8. :param file negative_examples: 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. Encode special characters in the file name in UTF-8. :param dict headers: A dict containing the request headers :return: A dict containing the Classifier response. :rtype: dict

update_classifier(classifier_id, **kwargs)[source]

Update a classifier. :param str classifier_id: The ID of the classifier. :param file <NAME>_positive_examples: 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. Include at least 10 images in .jpg or .png format. The minimum recommended image resolution is 32X32 pixels. The maximum number of images is 10,000 images or 100 MB per .zip file. Encode special characters in the file name in UTF-8. :param file negative_examples: 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. Encode special characters in the file name in UTF-8. :param dict headers: A dict containing the request headers :return: A dict containing the Classifier response. :rtype: dict

classify(images_file=None, accept_language=None, url=None, threshold=None, owners=None, classifier_ids=None, images_file_content_type=None, images_filename=None, **kwargs)[source]

Classify images.

Classify images with built-in or custom classifiers.

Parameters:images_file (file) – An image file (.jpg, .png) 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. You can also include an image with the url parameter. :param str accept_language: The language of the output class names. The full set of languages is supported for the built-in classifier IDs: default, food, and explicit. The 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. :param str url: The URL of an image to analyze. Must be in .jpg, or .png format. The minimum recommended pixel density is 32X32 pixels per inch, and the maximum image size is 10 MB. You can also include images with the images_file parameter. :param float threshold: The minimum score a class must have to be displayed in the response. Set the threshold to 0.0 to ignore the classification score and return all values. :param list[str] owners: The categories of classifiers to apply. Use IBM to classify against the default general classifier, and use me to classify against your custom classifiers. To analyze the image against both classifier categories, set the value to both IBM and me. The built-in default classifier is used if both classifier_ids and owners parameters are empty. The classifier_ids parameter overrides owners, so make sure that classifier_ids is empty. :param list[str] classifier_ids: 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. The following built-in classifier IDs require no training: - default: Returns classes from thousands of general tags. - food: Enhances specificity and accuracy for images of food items. - explicit: Evaluates whether the image might be pornographic. :param str images_file_content_type: The content type of images_file. :param str images_filename: The filename for images_file. :param dict headers: A dict containing the request headers :return: A DetailedResponse containing the result, headers and HTTP status code. :rtype: DetailedResponse