Skip to content

Commit

Permalink
Generated from bd6c66b615b94480a1458dde3a8bc42f3a689548 (#2645)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
AutorestCI committed Jun 21, 2018
1 parent b957717 commit 62c4025
Show file tree
Hide file tree
Showing 13 changed files with 271 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 = {}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 = {}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -75,7 +81,6 @@
OcrLanguages,
AzureRegions,
Details,
DomainModels,
)

__all__ = [
Expand Down Expand Up @@ -103,6 +108,9 @@
'ModelDescription',
'ListModelsResult',
'DomainModelResults',
'CelebrityResults',
'LandmarkResultsLandmarksItem',
'LandmarkResults',
'ImageDescription',
'TagResult',
'ComputerVisionError', 'ComputerVisionErrorException',
Expand All @@ -114,5 +122,4 @@
'OcrLanguages',
'AzureRegions',
'Details',
'DomainModels',
]
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,3 @@ class Details(str, Enum):

celebrities = "Celebrities"
landmarks = "Landmarks"


class DomainModels(str, Enum):

celebrities = "Celebrities"
landmarks = "Landmarks"
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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)
Loading

0 comments on commit 62c4025

Please sign in to comment.