diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_api.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_api.py index db22d1d994e0..37c45a8a14e1 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_api.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_api.py @@ -548,7 +548,7 @@ def tag_image( tag_image.metadata = {'url': '/tag'} def analyze_image_by_domain( - self, model, url, custom_headers=None, raw=False, **operation_config): + self, model, url, language="en", custom_headers=None, raw=False, **operation_config): """This operation recognizes content within an image by applying a domain-specific model. The list of domain-specific models that are supported by the Computer Vision API can be retrieved using the /models @@ -558,12 +558,16 @@ def analyze_image_by_domain( returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong. - :param model: The domain-specific content to recognize. Possible - values include: 'Celebrities', 'Landmarks' - :type model: str or - ~azure.cognitiveservices.vision.computervision.models.DomainModels + :param model: The domain-specific content to recognize. + :type model: str :param url: Publicly reachable URL of an image :type url: str + :param language: The desired language for output generation. If this + parameter is not specified, the default value is + "en".Supported languages:en - English, Default.ja - Japanese + pt - Portuguese zh - Simplified Chinese. Possible values include: + 'en', 'ja', 'pt', 'zh' + :type language: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -582,12 +586,14 @@ def analyze_image_by_domain( url = self.analyze_image_by_domain.metadata['url'] path_format_arguments = { 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True), - 'model': self._serialize.url("model", model, 'DomainModels') + 'model': self._serialize.url("model", model, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} + if language is not None: + query_parameters['language'] = self._serialize.query("language", language, 'str') # Construct headers header_parameters = {} @@ -1077,7 +1083,7 @@ def describe_image_in_stream( describe_image_in_stream.metadata = {'url': '/describe'} def tag_image_in_stream( - self, image, custom_headers=None, raw=False, callback=None, **operation_config): + self, image, language="en", custom_headers=None, raw=False, callback=None, **operation_config): """This operation generates a list of words, or tags, that are relevant to the content of the supplied image. The Computer Vision API can return tags based on objects, living beings, scenery or actions found in @@ -1089,6 +1095,12 @@ def tag_image_in_stream( :param image: An image stream. :type image: Generator + :param language: The desired language for output generation. If this + parameter is not specified, the default value is + "en".Supported languages:en - English, Default.ja - Japanese + pt - Portuguese zh - Simplified Chinese. Possible values include: + 'en', 'ja', 'pt', 'zh' + :type language: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1115,6 +1127,8 @@ def tag_image_in_stream( # Construct parameters query_parameters = {} + if language is not None: + query_parameters['language'] = self._serialize.query("language", language, 'str') # Construct headers header_parameters = {} @@ -1146,7 +1160,7 @@ def tag_image_in_stream( tag_image_in_stream.metadata = {'url': '/tag'} def analyze_image_by_domain_in_stream( - self, model, image, custom_headers=None, raw=False, callback=None, **operation_config): + self, model, image, language="en", custom_headers=None, raw=False, callback=None, **operation_config): """This operation recognizes content within an image by applying a domain-specific model. The list of domain-specific models that are supported by the Computer Vision API can be retrieved using the /models @@ -1160,6 +1174,12 @@ def analyze_image_by_domain_in_stream( :type model: str :param image: An image stream. :type image: Generator + :param language: The desired language for output generation. If this + parameter is not specified, the default value is + "en".Supported languages:en - English, Default.ja - Japanese + pt - Portuguese zh - Simplified Chinese. Possible values include: + 'en', 'ja', 'pt', 'zh' + :type language: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1187,6 +1207,8 @@ def analyze_image_by_domain_in_stream( # Construct parameters query_parameters = {} + if language is not None: + query_parameters['language'] = self._serialize.query("language", language, 'str') # Construct headers header_parameters = {} diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py index 663008ab4f8c..f0dde33bd544 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py @@ -34,6 +34,9 @@ from .model_description_py3 import ModelDescription from .list_models_result_py3 import ListModelsResult from .domain_model_results_py3 import DomainModelResults + from .celebrity_results_py3 import CelebrityResults + from .landmark_results_landmarks_item_py3 import LandmarkResultsLandmarksItem + from .landmark_results_py3 import LandmarkResults from .image_description_py3 import ImageDescription from .tag_result_py3 import TagResult from .computer_vision_error_py3 import ComputerVisionError, ComputerVisionErrorException @@ -63,6 +66,9 @@ from .model_description import ModelDescription from .list_models_result import ListModelsResult from .domain_model_results import DomainModelResults + from .celebrity_results import CelebrityResults + from .landmark_results_landmarks_item import LandmarkResultsLandmarksItem + from .landmark_results import LandmarkResults from .image_description import ImageDescription from .tag_result import TagResult from .computer_vision_error import ComputerVisionError, ComputerVisionErrorException @@ -75,7 +81,6 @@ OcrLanguages, AzureRegions, Details, - DomainModels, ) __all__ = [ @@ -103,6 +108,9 @@ 'ModelDescription', 'ListModelsResult', 'DomainModelResults', + 'CelebrityResults', + 'LandmarkResultsLandmarksItem', + 'LandmarkResults', 'ImageDescription', 'TagResult', 'ComputerVisionError', 'ComputerVisionErrorException', @@ -114,5 +122,4 @@ 'OcrLanguages', 'AzureRegions', 'Details', - 'DomainModels', ] diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrity_results.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrity_results.py new file mode 100644 index 000000000000..84b07c34ecbc --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrity_results.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class CelebrityResults(Model): + """List of celebrities recognized in the image. + + :param celebrities: + :type celebrities: + list[~azure.cognitiveservices.vision.computervision.models.CelebritiesModel] + :param request_id: Id of the REST API request. + :type request_id: str + :param metadata: + :type metadata: + ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + """ + + _attribute_map = { + 'celebrities': {'key': 'celebrities', 'type': '[CelebritiesModel]'}, + 'request_id': {'key': 'requestId', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + } + + def __init__(self, **kwargs): + super(CelebrityResults, self).__init__(**kwargs) + self.celebrities = kwargs.get('celebrities', None) + self.request_id = kwargs.get('request_id', None) + self.metadata = kwargs.get('metadata', None) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrity_results_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrity_results_py3.py new file mode 100644 index 000000000000..b6edc077463e --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/celebrity_results_py3.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class CelebrityResults(Model): + """List of celebrities recognized in the image. + + :param celebrities: + :type celebrities: + list[~azure.cognitiveservices.vision.computervision.models.CelebritiesModel] + :param request_id: Id of the REST API request. + :type request_id: str + :param metadata: + :type metadata: + ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + """ + + _attribute_map = { + 'celebrities': {'key': 'celebrities', 'type': '[CelebritiesModel]'}, + 'request_id': {'key': 'requestId', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + } + + def __init__(self, *, celebrities=None, request_id: str=None, metadata=None, **kwargs) -> None: + super(CelebrityResults, self).__init__(**kwargs) + self.celebrities = celebrities + self.request_id = request_id + self.metadata = metadata diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_api_enums.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_api_enums.py index e8ce61ec14bb..76ff22284087 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_api_enums.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_api_enums.py @@ -105,9 +105,3 @@ class Details(str, Enum): celebrities = "Celebrities" landmarks = "Landmarks" - - -class DomainModels(str, Enum): - - celebrities = "Celebrities" - landmarks = "Landmarks" diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results.py index 4093d33791b5..dba10b4cb224 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results.py @@ -16,10 +16,8 @@ class DomainModelResults(Model): """Result of image analysis using a specific domain model including additional metadata. - :param celebrities: An array of possible celebritied identified in the - image. - :type celebrities: - list[~azure.cognitiveservices.vision.computervision.models.CelebritiesModel] + :param result: Model-specific response + :type result: object :param request_id: Id of the REST API request. :type request_id: str :param metadata: @@ -28,13 +26,13 @@ class DomainModelResults(Model): """ _attribute_map = { - 'celebrities': {'key': 'result.celebrities', 'type': '[CelebritiesModel]'}, + 'result': {'key': 'result', 'type': 'object'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, } def __init__(self, **kwargs): super(DomainModelResults, self).__init__(**kwargs) - self.celebrities = kwargs.get('celebrities', None) + self.result = kwargs.get('result', None) self.request_id = kwargs.get('request_id', None) self.metadata = kwargs.get('metadata', None) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results_py3.py index ea639d2d2fc8..4b718b2258a7 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results_py3.py @@ -16,10 +16,8 @@ class DomainModelResults(Model): """Result of image analysis using a specific domain model including additional metadata. - :param celebrities: An array of possible celebritied identified in the - image. - :type celebrities: - list[~azure.cognitiveservices.vision.computervision.models.CelebritiesModel] + :param result: Model-specific response + :type result: object :param request_id: Id of the REST API request. :type request_id: str :param metadata: @@ -28,13 +26,13 @@ class DomainModelResults(Model): """ _attribute_map = { - 'celebrities': {'key': 'result.celebrities', 'type': '[CelebritiesModel]'}, + 'result': {'key': 'result', 'type': 'object'}, 'request_id': {'key': 'requestId', 'type': 'str'}, 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, } - def __init__(self, *, celebrities=None, request_id: str=None, metadata=None, **kwargs) -> None: + def __init__(self, *, result=None, request_id: str=None, metadata=None, **kwargs) -> None: super(DomainModelResults, self).__init__(**kwargs) - self.celebrities = celebrities + self.result = result self.request_id = request_id self.metadata = metadata diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results.py new file mode 100644 index 000000000000..14bd0e21d982 --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LandmarkResults(Model): + """List of landmarks recognized in the image. + + :param landmarks: + :type landmarks: + list[~azure.cognitiveservices.vision.computervision.models.LandmarkResultsLandmarksItem] + :param request_id: Id of the REST API request. + :type request_id: str + :param metadata: + :type metadata: + ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + """ + + _attribute_map = { + 'landmarks': {'key': 'landmarks', 'type': '[LandmarkResultsLandmarksItem]'}, + 'request_id': {'key': 'requestId', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + } + + def __init__(self, **kwargs): + super(LandmarkResults, self).__init__(**kwargs) + self.landmarks = kwargs.get('landmarks', None) + self.request_id = kwargs.get('request_id', None) + self.metadata = kwargs.get('metadata', None) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results_landmarks_item.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results_landmarks_item.py new file mode 100644 index 000000000000..fd4de1c7afbc --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results_landmarks_item.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LandmarkResultsLandmarksItem(Model): + """A landmark recognized in the image. + + :param name: Name of the landmark. + :type name: str + :param confidence: Confidence level for the landmark recognition. + :type confidence: float + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(LandmarkResultsLandmarksItem, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.confidence = kwargs.get('confidence', None) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results_landmarks_item_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results_landmarks_item_py3.py new file mode 100644 index 000000000000..69efe9302103 --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results_landmarks_item_py3.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LandmarkResultsLandmarksItem(Model): + """A landmark recognized in the image. + + :param name: Name of the landmark. + :type name: str + :param confidence: Confidence level for the landmark recognition. + :type confidence: float + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'confidence': {'key': 'confidence', 'type': 'float'}, + } + + def __init__(self, *, name: str=None, confidence: float=None, **kwargs) -> None: + super(LandmarkResultsLandmarksItem, self).__init__(**kwargs) + self.name = name + self.confidence = confidence diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results_py3.py new file mode 100644 index 000000000000..1df503e9eccf --- /dev/null +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/landmark_results_py3.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LandmarkResults(Model): + """List of landmarks recognized in the image. + + :param landmarks: + :type landmarks: + list[~azure.cognitiveservices.vision.computervision.models.LandmarkResultsLandmarksItem] + :param request_id: Id of the REST API request. + :type request_id: str + :param metadata: + :type metadata: + ~azure.cognitiveservices.vision.computervision.models.ImageMetadata + """ + + _attribute_map = { + 'landmarks': {'key': 'landmarks', 'type': '[LandmarkResultsLandmarksItem]'}, + 'request_id': {'key': 'requestId', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': 'ImageMetadata'}, + } + + def __init__(self, *, landmarks=None, request_id: str=None, metadata=None, **kwargs) -> None: + super(LandmarkResults, self).__init__(**kwargs) + self.landmarks = landmarks + self.request_id = request_id + self.metadata = metadata diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_result.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_result.py index eb573d1338e7..854514692604 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_result.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_result.py @@ -15,9 +15,8 @@ class OcrResult(Model): """OcrResult. - :param language: - :type language: - ~azure.cognitiveservices.vision.computervision.models.OcrResult + :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 respect to the closest horizontal or vertical direction. After rotating the input image clockwise by this angle, the recognized text lines become @@ -41,7 +40,7 @@ class OcrResult(Model): """ _attribute_map = { - 'language': {'key': 'language', 'type': 'OcrResult'}, + 'language': {'key': 'language', 'type': 'str'}, 'text_angle': {'key': 'textAngle', 'type': 'float'}, 'orientation': {'key': 'orientation', 'type': 'str'}, 'regions': {'key': 'regions', 'type': '[OcrRegion]'}, diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_result_py3.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_result_py3.py index 413fb9637d4e..6d654eac5891 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_result_py3.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/ocr_result_py3.py @@ -15,9 +15,8 @@ class OcrResult(Model): """OcrResult. - :param language: - :type language: - ~azure.cognitiveservices.vision.computervision.models.OcrResult + :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 respect to the closest horizontal or vertical direction. After rotating the input image clockwise by this angle, the recognized text lines become @@ -41,13 +40,13 @@ class OcrResult(Model): """ _attribute_map = { - 'language': {'key': 'language', 'type': 'OcrResult'}, + 'language': {'key': 'language', 'type': 'str'}, 'text_angle': {'key': 'textAngle', 'type': 'float'}, 'orientation': {'key': 'orientation', 'type': 'str'}, 'regions': {'key': 'regions', 'type': '[OcrRegion]'}, } - def __init__(self, *, language=None, text_angle: float=None, orientation: str=None, regions=None, **kwargs) -> None: + def __init__(self, *, language: str=None, text_angle: float=None, orientation: str=None, regions=None, **kwargs) -> None: super(OcrResult, self).__init__(**kwargs) self.language = language self.text_angle = text_angle