diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_computer_vision_client.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_computer_vision_client.py index c72b5b090410..66db7e8147cd 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_computer_vision_client.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_computer_vision_client.py @@ -38,7 +38,7 @@ def __init__( super(ComputerVisionClient, self).__init__(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '2.0' + self.api_version = '2.1' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_configuration.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_configuration.py index 717a630fe467..4231ac56a0a4 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_configuration.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/_configuration.py @@ -33,7 +33,7 @@ def __init__( raise ValueError("Parameter 'endpoint' must not be None.") if credentials is None: raise ValueError("Parameter 'credentials' must not be None.") - base_url = '{Endpoint}/vision/v2.0' + base_url = '{Endpoint}/vision/v2.1' super(ComputerVisionClientConfiguration, self).__init__(base_url) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py index dbfbd062db03..98057e314d77 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py @@ -88,6 +88,7 @@ from ._models import TextRecognitionResult from ._models import Word from ._computer_vision_client_enums import ( + DescriptionExclude, Details, Gender, OcrLanguages, @@ -141,6 +142,7 @@ 'TextOperationStatusCodes', 'TextRecognitionResultDimensionUnit', 'TextRecognitionResultConfidenceClass', + 'DescriptionExclude', 'OcrLanguages', 'VisualFeatureTypes', 'TextRecognitionMode', diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_computer_vision_client_enums.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_computer_vision_client_enums.py index b799691f5649..2c319134cff0 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_computer_vision_client_enums.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_computer_vision_client_enums.py @@ -38,6 +38,12 @@ class TextRecognitionResultConfidenceClass(str, Enum): low = "Low" +class DescriptionExclude(str, Enum): + + celebrities = "Celebrities" + landmarks = "Landmarks" + + class OcrLanguages(str, Enum): unk = "unk" diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models.py index acc3f269660c..1954cb533892 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models.py @@ -22,27 +22,35 @@ class AdultInfo(Model): :type is_adult_content: bool :param is_racy_content: A value indicating if the image is racy. :type is_racy_content: bool + :param is_gory_content: A value indicating if the image is gory. + :type is_gory_content: bool :param adult_score: Score from 0 to 1 that indicates how much the content is considered adult-oriented within the image. :type adult_score: float :param racy_score: Score from 0 to 1 that indicates how suggestive is the image. :type racy_score: float + :param gore_score: Score from 0 to 1 that indicates how gory is the image. + :type gore_score: float """ _attribute_map = { 'is_adult_content': {'key': 'isAdultContent', 'type': 'bool'}, 'is_racy_content': {'key': 'isRacyContent', 'type': 'bool'}, + 'is_gory_content': {'key': 'isGoryContent', 'type': 'bool'}, 'adult_score': {'key': 'adultScore', 'type': 'float'}, 'racy_score': {'key': 'racyScore', 'type': 'float'}, + 'gore_score': {'key': 'goreScore', 'type': 'float'}, } def __init__(self, **kwargs): super(AdultInfo, self).__init__(**kwargs) self.is_adult_content = kwargs.get('is_adult_content', None) self.is_racy_content = kwargs.get('is_racy_content', None) + self.is_gory_content = kwargs.get('is_gory_content', None) self.adult_score = kwargs.get('adult_score', None) self.racy_score = kwargs.get('racy_score', None) + self.gore_score = kwargs.get('gore_score', None) class AreaOfInterestResult(Model): @@ -912,7 +920,7 @@ class OcrResult(Model): :param language: The BCP-47 language code of the text in the image. :type language: str - :param text_angle: The angle, in degrees, of the detected text with + :param text_angle: The angle, in radians, of the detected text with respect to the closest horizontal or vertical direction. After rotating the input image clockwise by this angle, the recognized text lines become horizontal or vertical. In combination with the orientation property it @@ -923,10 +931,13 @@ class OcrResult(Model): contains text at different angles, only part of the text will be recognized correctly. :type text_angle: float - :param orientation: Orientation of the text recognized in the image. The - value (up, down, left, or right) refers to the direction that the top of - the recognized text is facing, after the image has been rotated around its - center according to the detected text angle (see textAngle property). + :param orientation: Orientation of the text recognized in the image, if + requested. The value (up, down, left, or right) refers to the direction + that the top of the recognized text is facing, after the image has been + rotated around its center according to the detected text angle (see + textAngle property). + If detection of the orientation was not requested, or no text is detected, + the value is 'NotDetected'. :type orientation: str :param regions: An array of objects, where each object represents a region of recognized text. diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models_py3.py index 826fa3707719..0df15fb9e295 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models_py3.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/_models_py3.py @@ -22,27 +22,35 @@ class AdultInfo(Model): :type is_adult_content: bool :param is_racy_content: A value indicating if the image is racy. :type is_racy_content: bool + :param is_gory_content: A value indicating if the image is gory. + :type is_gory_content: bool :param adult_score: Score from 0 to 1 that indicates how much the content is considered adult-oriented within the image. :type adult_score: float :param racy_score: Score from 0 to 1 that indicates how suggestive is the image. :type racy_score: float + :param gore_score: Score from 0 to 1 that indicates how gory is the image. + :type gore_score: float """ _attribute_map = { 'is_adult_content': {'key': 'isAdultContent', 'type': 'bool'}, 'is_racy_content': {'key': 'isRacyContent', 'type': 'bool'}, + 'is_gory_content': {'key': 'isGoryContent', 'type': 'bool'}, 'adult_score': {'key': 'adultScore', 'type': 'float'}, 'racy_score': {'key': 'racyScore', 'type': 'float'}, + 'gore_score': {'key': 'goreScore', 'type': 'float'}, } - def __init__(self, *, is_adult_content: bool=None, is_racy_content: bool=None, adult_score: float=None, racy_score: float=None, **kwargs) -> None: + def __init__(self, *, is_adult_content: bool=None, is_racy_content: bool=None, is_gory_content: bool=None, adult_score: float=None, racy_score: float=None, gore_score: float=None, **kwargs) -> None: super(AdultInfo, self).__init__(**kwargs) self.is_adult_content = is_adult_content self.is_racy_content = is_racy_content + self.is_gory_content = is_gory_content self.adult_score = adult_score self.racy_score = racy_score + self.gore_score = gore_score class AreaOfInterestResult(Model): @@ -912,7 +920,7 @@ class OcrResult(Model): :param language: The BCP-47 language code of the text in the image. :type language: str - :param text_angle: The angle, in degrees, of the detected text with + :param text_angle: The angle, in radians, of the detected text with respect to the closest horizontal or vertical direction. After rotating the input image clockwise by this angle, the recognized text lines become horizontal or vertical. In combination with the orientation property it @@ -923,10 +931,13 @@ class OcrResult(Model): contains text at different angles, only part of the text will be recognized correctly. :type text_angle: float - :param orientation: Orientation of the text recognized in the image. The - value (up, down, left, or right) refers to the direction that the top of - the recognized text is facing, after the image has been rotated around its - center according to the detected text angle (see textAngle property). + :param orientation: Orientation of the text recognized in the image, if + requested. The value (up, down, left, or right) refers to the direction + that the top of the recognized text is facing, after the image has been + rotated around its center according to the detected text angle (see + textAngle property). + If detection of the orientation was not requested, or no text is detected, + the value is 'NotDetected'. :type orientation: str :param regions: An array of objects, where each object represents a region of recognized text. diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/operations/_computer_vision_client_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/operations/_computer_vision_client_operations.py index a7d91b46d40f..3690d7aa9499 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/operations/_computer_vision_client_operations.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/operations/_computer_vision_client_operations.py @@ -17,7 +17,7 @@ class ComputerVisionClientOperationsMixin(object): def analyze_image( - self, url, visual_features=None, details=None, language="en", custom_headers=None, raw=False, **operation_config): + self, url, visual_features=None, details=None, language="en", description_exclude=None, custom_headers=None, raw=False, **operation_config): """This operation extracts a rich set of visual features based on the image content. Two input methods are supported -- (1) Uploading an image or (2) @@ -40,12 +40,13 @@ def analyze_image( coordinates, gender and age. ImageType - detects if image is clipart or a line drawing. Color - determines the accent color, dominant color, and whether an image is black&white. Adult - detects if the - image is pornographic in nature (depicts nudity or a sex act). - Sexually suggestive content is also detected. Objects - detects - various objects within an image, including the approximate location. - The Objects argument is only available in English. Brands - detects - various brands within an image, including the approximate location. - The Brands argument is only available in English. + image is pornographic in nature (depicts nudity or a sex act), or is + gory (depicts extreme violence or blood). Sexually suggestive content + (aka racy content) is also detected. Objects - detects various objects + within an image, including the approximate location. The Objects + argument is only available in English. Brands - detects various brands + within an image, including the approximate location. The Brands + argument is only available in English. :type visual_features: list[str or ~azure.cognitiveservices.vision.computervision.models.VisualFeatureTypes] :param details: A string indicating which domain-specific details to @@ -61,6 +62,10 @@ def analyze_image( Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es', 'ja', 'pt', 'zh' :type language: str + :param description_exclude: Turn off specified domain models when + generating the description. + :type description_exclude: list[str or + ~azure.cognitiveservices.vision.computervision.models.DescriptionExclude] :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -90,6 +95,8 @@ def analyze_image( query_parameters['details'] = self._serialize.query("details", details, '[Details]', div=',') if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'str') + if description_exclude is not None: + query_parameters['descriptionExclude'] = self._serialize.query("description_exclude", description_exclude, '[DescriptionExclude]', div=',') # Construct headers header_parameters = {} @@ -120,12 +127,13 @@ def analyze_image( analyze_image.metadata = {'url': '/analyze'} def describe_image( - self, url, max_candidates=1, language="en", custom_headers=None, raw=False, **operation_config): + self, url, max_candidates=1, language="en", description_exclude=None, custom_headers=None, raw=False, **operation_config): """This operation generates a description of an image in human readable language with complete sentences. The description is based on a collection of content tags, which are also returned by the operation. More than one description can be generated for each image. Descriptions - are ordered by their confidence score. All descriptions are in English. + are ordered by their confidence score. Descriptions may include results + from celebrity and landmark domain models, if applicable. Two input methods are supported -- (1) Uploading an image or (2) specifying an image URL. A successful response will be returned in JSON. If the request failed, @@ -143,6 +151,10 @@ def describe_image( Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es', 'ja', 'pt', 'zh' :type language: str + :param description_exclude: Turn off specified domain models when + generating the description. + :type description_exclude: list[str or + ~azure.cognitiveservices.vision.computervision.models.DescriptionExclude] :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -170,6 +182,8 @@ def describe_image( query_parameters['maxCandidates'] = self._serialize.query("max_candidates", max_candidates, 'int') if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'str') + if description_exclude is not None: + query_parameters['descriptionExclude'] = self._serialize.query("description_exclude", description_exclude, '[DescriptionExclude]', div=',') # Construct headers header_parameters = {} @@ -484,8 +498,7 @@ def tag_image( images. Unlike categories, tags are not organized according to a hierarchical classification system, but correspond to image content. Tags may contain hints to avoid ambiguity or provide context, for - example the tag "cello" may be accompanied by the hint "musical - instrument". All tags are in English. + example the tag "ascomycete" may be accompanied by the hint "fungus". Two input methods are supported -- (1) Uploading an image or (2) specifying an image URL. A successful response will be returned in JSON. If the request failed, @@ -932,7 +945,7 @@ def get_read_operation_result( get_read_operation_result.metadata = {'url': '/read/operations/{operationId}'} def analyze_image_in_stream( - self, image, visual_features=None, details=None, language="en", custom_headers=None, raw=False, callback=None, **operation_config): + self, image, visual_features=None, details=None, language="en", description_exclude=None, custom_headers=None, raw=False, callback=None, **operation_config): """This operation extracts a rich set of visual features based on the image content. Two input methods are supported -- (1) Uploading an image or (2) @@ -955,12 +968,13 @@ def analyze_image_in_stream( coordinates, gender and age. ImageType - detects if image is clipart or a line drawing. Color - determines the accent color, dominant color, and whether an image is black&white. Adult - detects if the - image is pornographic in nature (depicts nudity or a sex act). - Sexually suggestive content is also detected. Objects - detects - various objects within an image, including the approximate location. - The Objects argument is only available in English. Brands - detects - various brands within an image, including the approximate location. - The Brands argument is only available in English. + image is pornographic in nature (depicts nudity or a sex act), or is + gory (depicts extreme violence or blood). Sexually suggestive content + (aka racy content) is also detected. Objects - detects various objects + within an image, including the approximate location. The Objects + argument is only available in English. Brands - detects various brands + within an image, including the approximate location. The Brands + argument is only available in English. :type visual_features: list[str or ~azure.cognitiveservices.vision.computervision.models.VisualFeatureTypes] :param details: A string indicating which domain-specific details to @@ -976,6 +990,10 @@ def analyze_image_in_stream( Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es', 'ja', 'pt', 'zh' :type language: str + :param description_exclude: Turn off specified domain models when + generating the description. + :type description_exclude: list[str or + ~azure.cognitiveservices.vision.computervision.models.DescriptionExclude] :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1008,6 +1026,8 @@ def analyze_image_in_stream( query_parameters['details'] = self._serialize.query("details", details, '[Details]', div=',') if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'str') + if description_exclude is not None: + query_parameters['descriptionExclude'] = self._serialize.query("description_exclude", description_exclude, '[DescriptionExclude]', div=',') # Construct headers header_parameters = {} @@ -1107,12 +1127,13 @@ def get_area_of_interest_in_stream( get_area_of_interest_in_stream.metadata = {'url': '/areaOfInterest'} def describe_image_in_stream( - self, image, max_candidates=1, language="en", custom_headers=None, raw=False, callback=None, **operation_config): + self, image, max_candidates=1, language="en", description_exclude=None, custom_headers=None, raw=False, callback=None, **operation_config): """This operation generates a description of an image in human readable language with complete sentences. The description is based on a collection of content tags, which are also returned by the operation. More than one description can be generated for each image. Descriptions - are ordered by their confidence score. All descriptions are in English. + are ordered by their confidence score. Descriptions may include results + from celebrity and landmark domain models, if applicable. Two input methods are supported -- (1) Uploading an image or (2) specifying an image URL. A successful response will be returned in JSON. If the request failed, @@ -1130,6 +1151,10 @@ def describe_image_in_stream( Spanish, ja - Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: 'en', 'es', 'ja', 'pt', 'zh' :type language: str + :param description_exclude: Turn off specified domain models when + generating the description. + :type description_exclude: list[str or + ~azure.cognitiveservices.vision.computervision.models.DescriptionExclude] :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1160,6 +1185,8 @@ def describe_image_in_stream( query_parameters['maxCandidates'] = self._serialize.query("max_candidates", max_candidates, 'int') if language is not None: query_parameters['language'] = self._serialize.query("language", language, 'str') + if description_exclude is not None: + query_parameters['descriptionExclude'] = self._serialize.query("description_exclude", description_exclude, '[DescriptionExclude]', div=',') # Construct headers header_parameters = {} @@ -1507,8 +1534,7 @@ def tag_image_in_stream( images. Unlike categories, tags are not organized according to a hierarchical classification system, but correspond to image content. Tags may contain hints to avoid ambiguity or provide context, for - example the tag "cello" may be accompanied by the hint "musical - instrument". All tags are in English. + example the tag "ascomycete" may be accompanied by the hint "fungus". Two input methods are supported -- (1) Uploading an image or (2) specifying an image URL. A successful response will be returned in JSON. If the request failed,