Skip to content

Commit 56ef731

Browse files
authored
Generated from bd6c66b615b94480a1458dde3a8bc42f3a689548 (#2645)
ComputerVision - collection of fixes * fix ocr language parameter to fix [bug](Azure/azure-sdk-for-net#4083) * language parameter missing for /tag path * language parameter missing for /models/*/analyze path * make /models/*/analyze return a more generic type * add specific types for /models/*/analyze to return for current models
1 parent a203d19 commit 56ef731

13 files changed

+271
-38
lines changed

azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_api.py

+30-8
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ def tag_image(
548548
tag_image.metadata = {'url': '/tag'}
549549

550550
def analyze_image_by_domain(
551-
self, model, url, custom_headers=None, raw=False, **operation_config):
551+
self, model, url, language="en", custom_headers=None, raw=False, **operation_config):
552552
"""This operation recognizes content within an image by applying a
553553
domain-specific model. The list of domain-specific models that are
554554
supported by the Computer Vision API can be retrieved using the /models
@@ -558,12 +558,16 @@ def analyze_image_by_domain(
558558
returned in JSON. If the request failed, the response will contain an
559559
error code and a message to help understand what went wrong.
560560
561-
:param model: The domain-specific content to recognize. Possible
562-
values include: 'Celebrities', 'Landmarks'
563-
:type model: str or
564-
~azure.cognitiveservices.vision.computervision.models.DomainModels
561+
:param model: The domain-specific content to recognize.
562+
:type model: str
565563
:param url: Publicly reachable URL of an image
566564
:type url: str
565+
:param language: The desired language for output generation. If this
566+
parameter is not specified, the default value is
567+
"en".Supported languages:en - English, Default.ja - Japanese
568+
pt - Portuguese zh - Simplified Chinese. Possible values include:
569+
'en', 'ja', 'pt', 'zh'
570+
:type language: str
567571
:param dict custom_headers: headers that will be added to the request
568572
:param bool raw: returns the direct response alongside the
569573
deserialized response
@@ -582,12 +586,14 @@ def analyze_image_by_domain(
582586
url = self.analyze_image_by_domain.metadata['url']
583587
path_format_arguments = {
584588
'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True),
585-
'model': self._serialize.url("model", model, 'DomainModels')
589+
'model': self._serialize.url("model", model, 'str')
586590
}
587591
url = self._client.format_url(url, **path_format_arguments)
588592

589593
# Construct parameters
590594
query_parameters = {}
595+
if language is not None:
596+
query_parameters['language'] = self._serialize.query("language", language, 'str')
591597

592598
# Construct headers
593599
header_parameters = {}
@@ -1077,7 +1083,7 @@ def describe_image_in_stream(
10771083
describe_image_in_stream.metadata = {'url': '/describe'}
10781084

10791085
def tag_image_in_stream(
1080-
self, image, custom_headers=None, raw=False, callback=None, **operation_config):
1086+
self, image, language="en", custom_headers=None, raw=False, callback=None, **operation_config):
10811087
"""This operation generates a list of words, or tags, that are relevant to
10821088
the content of the supplied image. The Computer Vision API can return
10831089
tags based on objects, living beings, scenery or actions found in
@@ -1089,6 +1095,12 @@ def tag_image_in_stream(
10891095
10901096
:param image: An image stream.
10911097
:type image: Generator
1098+
:param language: The desired language for output generation. If this
1099+
parameter is not specified, the default value is
1100+
"en".Supported languages:en - English, Default.ja - Japanese
1101+
pt - Portuguese zh - Simplified Chinese. Possible values include:
1102+
'en', 'ja', 'pt', 'zh'
1103+
:type language: str
10921104
:param dict custom_headers: headers that will be added to the request
10931105
:param bool raw: returns the direct response alongside the
10941106
deserialized response
@@ -1115,6 +1127,8 @@ def tag_image_in_stream(
11151127

11161128
# Construct parameters
11171129
query_parameters = {}
1130+
if language is not None:
1131+
query_parameters['language'] = self._serialize.query("language", language, 'str')
11181132

11191133
# Construct headers
11201134
header_parameters = {}
@@ -1146,7 +1160,7 @@ def tag_image_in_stream(
11461160
tag_image_in_stream.metadata = {'url': '/tag'}
11471161

11481162
def analyze_image_by_domain_in_stream(
1149-
self, model, image, custom_headers=None, raw=False, callback=None, **operation_config):
1163+
self, model, image, language="en", custom_headers=None, raw=False, callback=None, **operation_config):
11501164
"""This operation recognizes content within an image by applying a
11511165
domain-specific model. The list of domain-specific models that are
11521166
supported by the Computer Vision API can be retrieved using the /models
@@ -1160,6 +1174,12 @@ def analyze_image_by_domain_in_stream(
11601174
:type model: str
11611175
:param image: An image stream.
11621176
:type image: Generator
1177+
:param language: The desired language for output generation. If this
1178+
parameter is not specified, the default value is
1179+
"en".Supported languages:en - English, Default.ja - Japanese
1180+
pt - Portuguese zh - Simplified Chinese. Possible values include:
1181+
'en', 'ja', 'pt', 'zh'
1182+
:type language: str
11631183
:param dict custom_headers: headers that will be added to the request
11641184
:param bool raw: returns the direct response alongside the
11651185
deserialized response
@@ -1187,6 +1207,8 @@ def analyze_image_by_domain_in_stream(
11871207

11881208
# Construct parameters
11891209
query_parameters = {}
1210+
if language is not None:
1211+
query_parameters['language'] = self._serialize.query("language", language, 'str')
11901212

11911213
# Construct headers
11921214
header_parameters = {}

azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
from .model_description_py3 import ModelDescription
3535
from .list_models_result_py3 import ListModelsResult
3636
from .domain_model_results_py3 import DomainModelResults
37+
from .celebrity_results_py3 import CelebrityResults
38+
from .landmark_results_landmarks_item_py3 import LandmarkResultsLandmarksItem
39+
from .landmark_results_py3 import LandmarkResults
3740
from .image_description_py3 import ImageDescription
3841
from .tag_result_py3 import TagResult
3942
from .computer_vision_error_py3 import ComputerVisionError, ComputerVisionErrorException
@@ -63,6 +66,9 @@
6366
from .model_description import ModelDescription
6467
from .list_models_result import ListModelsResult
6568
from .domain_model_results import DomainModelResults
69+
from .celebrity_results import CelebrityResults
70+
from .landmark_results_landmarks_item import LandmarkResultsLandmarksItem
71+
from .landmark_results import LandmarkResults
6672
from .image_description import ImageDescription
6773
from .tag_result import TagResult
6874
from .computer_vision_error import ComputerVisionError, ComputerVisionErrorException
@@ -75,7 +81,6 @@
7581
OcrLanguages,
7682
AzureRegions,
7783
Details,
78-
DomainModels,
7984
)
8085

8186
__all__ = [
@@ -103,6 +108,9 @@
103108
'ModelDescription',
104109
'ListModelsResult',
105110
'DomainModelResults',
111+
'CelebrityResults',
112+
'LandmarkResultsLandmarksItem',
113+
'LandmarkResults',
106114
'ImageDescription',
107115
'TagResult',
108116
'ComputerVisionError', 'ComputerVisionErrorException',
@@ -114,5 +122,4 @@
114122
'OcrLanguages',
115123
'AzureRegions',
116124
'Details',
117-
'DomainModels',
118125
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for
5+
# license information.
6+
#
7+
# Code generated by Microsoft (R) AutoRest Code Generator.
8+
# Changes may cause incorrect behavior and will be lost if the code is
9+
# regenerated.
10+
# --------------------------------------------------------------------------
11+
12+
from msrest.serialization import Model
13+
14+
15+
class CelebrityResults(Model):
16+
"""List of celebrities recognized in the image.
17+
18+
:param celebrities:
19+
:type celebrities:
20+
list[~azure.cognitiveservices.vision.computervision.models.CelebritiesModel]
21+
:param request_id: Id of the REST API request.
22+
:type request_id: str
23+
:param metadata:
24+
:type metadata:
25+
~azure.cognitiveservices.vision.computervision.models.ImageMetadata
26+
"""
27+
28+
_attribute_map = {
29+
'celebrities': {'key': 'celebrities', 'type': '[CelebritiesModel]'},
30+
'request_id': {'key': 'requestId', 'type': 'str'},
31+
'metadata': {'key': 'metadata', 'type': 'ImageMetadata'},
32+
}
33+
34+
def __init__(self, **kwargs):
35+
super(CelebrityResults, self).__init__(**kwargs)
36+
self.celebrities = kwargs.get('celebrities', None)
37+
self.request_id = kwargs.get('request_id', None)
38+
self.metadata = kwargs.get('metadata', None)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for
5+
# license information.
6+
#
7+
# Code generated by Microsoft (R) AutoRest Code Generator.
8+
# Changes may cause incorrect behavior and will be lost if the code is
9+
# regenerated.
10+
# --------------------------------------------------------------------------
11+
12+
from msrest.serialization import Model
13+
14+
15+
class CelebrityResults(Model):
16+
"""List of celebrities recognized in the image.
17+
18+
:param celebrities:
19+
:type celebrities:
20+
list[~azure.cognitiveservices.vision.computervision.models.CelebritiesModel]
21+
:param request_id: Id of the REST API request.
22+
:type request_id: str
23+
:param metadata:
24+
:type metadata:
25+
~azure.cognitiveservices.vision.computervision.models.ImageMetadata
26+
"""
27+
28+
_attribute_map = {
29+
'celebrities': {'key': 'celebrities', 'type': '[CelebritiesModel]'},
30+
'request_id': {'key': 'requestId', 'type': 'str'},
31+
'metadata': {'key': 'metadata', 'type': 'ImageMetadata'},
32+
}
33+
34+
def __init__(self, *, celebrities=None, request_id: str=None, metadata=None, **kwargs) -> None:
35+
super(CelebrityResults, self).__init__(**kwargs)
36+
self.celebrities = celebrities
37+
self.request_id = request_id
38+
self.metadata = metadata

azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_api_enums.py

-6
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,3 @@ class Details(str, Enum):
105105

106106
celebrities = "Celebrities"
107107
landmarks = "Landmarks"
108-
109-
110-
class DomainModels(str, Enum):
111-
112-
celebrities = "Celebrities"
113-
landmarks = "Landmarks"

azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ class DomainModelResults(Model):
1616
"""Result of image analysis using a specific domain model including additional
1717
metadata.
1818
19-
:param celebrities: An array of possible celebritied identified in the
20-
image.
21-
:type celebrities:
22-
list[~azure.cognitiveservices.vision.computervision.models.CelebritiesModel]
19+
:param result: Model-specific response
20+
:type result: object
2321
:param request_id: Id of the REST API request.
2422
:type request_id: str
2523
:param metadata:
@@ -28,13 +26,13 @@ class DomainModelResults(Model):
2826
"""
2927

3028
_attribute_map = {
31-
'celebrities': {'key': 'result.celebrities', 'type': '[CelebritiesModel]'},
29+
'result': {'key': 'result', 'type': 'object'},
3230
'request_id': {'key': 'requestId', 'type': 'str'},
3331
'metadata': {'key': 'metadata', 'type': 'ImageMetadata'},
3432
}
3533

3634
def __init__(self, **kwargs):
3735
super(DomainModelResults, self).__init__(**kwargs)
38-
self.celebrities = kwargs.get('celebrities', None)
36+
self.result = kwargs.get('result', None)
3937
self.request_id = kwargs.get('request_id', None)
4038
self.metadata = kwargs.get('metadata', None)

azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/domain_model_results_py3.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ class DomainModelResults(Model):
1616
"""Result of image analysis using a specific domain model including additional
1717
metadata.
1818
19-
:param celebrities: An array of possible celebritied identified in the
20-
image.
21-
:type celebrities:
22-
list[~azure.cognitiveservices.vision.computervision.models.CelebritiesModel]
19+
:param result: Model-specific response
20+
:type result: object
2321
:param request_id: Id of the REST API request.
2422
:type request_id: str
2523
:param metadata:
@@ -28,13 +26,13 @@ class DomainModelResults(Model):
2826
"""
2927

3028
_attribute_map = {
31-
'celebrities': {'key': 'result.celebrities', 'type': '[CelebritiesModel]'},
29+
'result': {'key': 'result', 'type': 'object'},
3230
'request_id': {'key': 'requestId', 'type': 'str'},
3331
'metadata': {'key': 'metadata', 'type': 'ImageMetadata'},
3432
}
3533

36-
def __init__(self, *, celebrities=None, request_id: str=None, metadata=None, **kwargs) -> None:
34+
def __init__(self, *, result=None, request_id: str=None, metadata=None, **kwargs) -> None:
3735
super(DomainModelResults, self).__init__(**kwargs)
38-
self.celebrities = celebrities
36+
self.result = result
3937
self.request_id = request_id
4038
self.metadata = metadata
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for
5+
# license information.
6+
#
7+
# Code generated by Microsoft (R) AutoRest Code Generator.
8+
# Changes may cause incorrect behavior and will be lost if the code is
9+
# regenerated.
10+
# --------------------------------------------------------------------------
11+
12+
from msrest.serialization import Model
13+
14+
15+
class LandmarkResults(Model):
16+
"""List of landmarks recognized in the image.
17+
18+
:param landmarks:
19+
:type landmarks:
20+
list[~azure.cognitiveservices.vision.computervision.models.LandmarkResultsLandmarksItem]
21+
:param request_id: Id of the REST API request.
22+
:type request_id: str
23+
:param metadata:
24+
:type metadata:
25+
~azure.cognitiveservices.vision.computervision.models.ImageMetadata
26+
"""
27+
28+
_attribute_map = {
29+
'landmarks': {'key': 'landmarks', 'type': '[LandmarkResultsLandmarksItem]'},
30+
'request_id': {'key': 'requestId', 'type': 'str'},
31+
'metadata': {'key': 'metadata', 'type': 'ImageMetadata'},
32+
}
33+
34+
def __init__(self, **kwargs):
35+
super(LandmarkResults, self).__init__(**kwargs)
36+
self.landmarks = kwargs.get('landmarks', None)
37+
self.request_id = kwargs.get('request_id', None)
38+
self.metadata = kwargs.get('metadata', None)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for
5+
# license information.
6+
#
7+
# Code generated by Microsoft (R) AutoRest Code Generator.
8+
# Changes may cause incorrect behavior and will be lost if the code is
9+
# regenerated.
10+
# --------------------------------------------------------------------------
11+
12+
from msrest.serialization import Model
13+
14+
15+
class LandmarkResultsLandmarksItem(Model):
16+
"""A landmark recognized in the image.
17+
18+
:param name: Name of the landmark.
19+
:type name: str
20+
:param confidence: Confidence level for the landmark recognition.
21+
:type confidence: float
22+
"""
23+
24+
_attribute_map = {
25+
'name': {'key': 'name', 'type': 'str'},
26+
'confidence': {'key': 'confidence', 'type': 'float'},
27+
}
28+
29+
def __init__(self, **kwargs):
30+
super(LandmarkResultsLandmarksItem, self).__init__(**kwargs)
31+
self.name = kwargs.get('name', None)
32+
self.confidence = kwargs.get('confidence', None)

0 commit comments

Comments
 (0)