Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR cognitiveservices/data-plane/ComputerVision] Analyze brands #4294

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions azure-cognitiveservices-vision-computervision/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,6 @@ This package has been tested with Python 2.7, 3.4, 3.5, 3.6 and 3.7.
For a more complete set of Azure libraries, see the `azure <https://pypi.python.org/pypi/azure>`__ bundle package.


Compatibility
=============

**IMPORTANT**: If you have an earlier version of the azure package
(version < 1.0), you should uninstall it before installing this package.

You can check the version using pip:

.. code:: shell

pip freeze

If you see azure==0.11.0 (or any version below 1.0), uninstall it first:

.. code:: shell

pip uninstall azure


Usage
=====

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,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}'
base_url = '{Endpoint}/vision/v2.0'

super(ComputerVisionClientConfiguration, self).__init__(base_url)

Expand Down Expand Up @@ -98,7 +98,9 @@ def analyze_image(
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.
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
Expand Down Expand Up @@ -910,7 +912,9 @@ def analyze_image_in_stream(
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.
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from .bounding_rect_py3 import BoundingRect
from .object_hierarchy_py3 import ObjectHierarchy
from .detected_object_py3 import DetectedObject
from .detected_brand_py3 import DetectedBrand
from .image_metadata_py3 import ImageMetadata
from .image_analysis_py3 import ImageAnalysis
from .image_description_py3 import ImageDescription
Expand Down Expand Up @@ -62,6 +63,7 @@
from .bounding_rect import BoundingRect
from .object_hierarchy import ObjectHierarchy
from .detected_object import DetectedObject
from .detected_brand import DetectedBrand
from .image_metadata import ImageMetadata
from .image_analysis import ImageAnalysis
from .image_description import ImageDescription
Expand Down Expand Up @@ -108,6 +110,7 @@
'BoundingRect',
'ObjectHierarchy',
'DetectedObject',
'DetectedBrand',
'ImageMetadata',
'ImageAnalysis',
'ImageDescription',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class VisualFeatureTypes(str, Enum):
tags = "Tags"
description = "Description"
objects = "Objects"
brands = "Brands"


class TextRecognitionMode(str, Enum):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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 DetectedBrand(Model):
"""A brand detected in an image.

Variables are only populated by the server, and will be ignored when
sending a request.

:ivar name: Label for the brand.
:vartype name: str
:ivar confidence: Confidence score of having observed the brand in the
image, as a value ranging from 0 to 1.
:vartype confidence: float
:ivar rectangle: Approximate location of the detected brand.
:vartype rectangle:
~azure.cognitiveservices.vision.computervision.models.BoundingRect
"""

_validation = {
'name': {'readonly': True},
'confidence': {'readonly': True},
'rectangle': {'readonly': True},
}

_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'confidence': {'key': 'confidence', 'type': 'float'},
'rectangle': {'key': 'rectangle', 'type': 'BoundingRect'},
}

def __init__(self, **kwargs):
super(DetectedBrand, self).__init__(**kwargs)
self.name = None
self.confidence = None
self.rectangle = None
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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 DetectedBrand(Model):
"""A brand detected in an image.

Variables are only populated by the server, and will be ignored when
sending a request.

:ivar name: Label for the brand.
:vartype name: str
:ivar confidence: Confidence score of having observed the brand in the
image, as a value ranging from 0 to 1.
:vartype confidence: float
:ivar rectangle: Approximate location of the detected brand.
:vartype rectangle:
~azure.cognitiveservices.vision.computervision.models.BoundingRect
"""

_validation = {
'name': {'readonly': True},
'confidence': {'readonly': True},
'rectangle': {'readonly': True},
}

_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'confidence': {'key': 'confidence', 'type': 'float'},
'rectangle': {'key': 'rectangle', 'type': 'BoundingRect'},
}

def __init__(self, **kwargs) -> None:
super(DetectedBrand, self).__init__(**kwargs)
self.name = None
self.confidence = None
self.rectangle = None
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class ImageAnalysis(Model):
image.
:type objects:
list[~azure.cognitiveservices.vision.computervision.models.DetectedObject]
:param brands: Array of brands detected in the image.
:type brands:
list[~azure.cognitiveservices.vision.computervision.models.DetectedBrand]
:param request_id: Id of the REST API request.
:type request_id: str
:param metadata:
Expand All @@ -60,6 +63,7 @@ class ImageAnalysis(Model):
'description': {'key': 'description', 'type': 'ImageDescriptionDetails'},
'faces': {'key': 'faces', 'type': '[FaceDescription]'},
'objects': {'key': 'objects', 'type': '[DetectedObject]'},
'brands': {'key': 'brands', 'type': '[DetectedBrand]'},
'request_id': {'key': 'requestId', 'type': 'str'},
'metadata': {'key': 'metadata', 'type': 'ImageMetadata'},
}
Expand All @@ -74,5 +78,6 @@ def __init__(self, **kwargs):
self.description = kwargs.get('description', None)
self.faces = kwargs.get('faces', None)
self.objects = kwargs.get('objects', None)
self.brands = kwargs.get('brands', 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 @@ -44,6 +44,9 @@ class ImageAnalysis(Model):
image.
:type objects:
list[~azure.cognitiveservices.vision.computervision.models.DetectedObject]
:param brands: Array of brands detected in the image.
:type brands:
list[~azure.cognitiveservices.vision.computervision.models.DetectedBrand]
:param request_id: Id of the REST API request.
:type request_id: str
:param metadata:
Expand All @@ -60,11 +63,12 @@ class ImageAnalysis(Model):
'description': {'key': 'description', 'type': 'ImageDescriptionDetails'},
'faces': {'key': 'faces', 'type': '[FaceDescription]'},
'objects': {'key': 'objects', 'type': '[DetectedObject]'},
'brands': {'key': 'brands', 'type': '[DetectedBrand]'},
'request_id': {'key': 'requestId', 'type': 'str'},
'metadata': {'key': 'metadata', 'type': 'ImageMetadata'},
}

def __init__(self, *, categories=None, adult=None, color=None, image_type=None, tags=None, description=None, faces=None, objects=None, request_id: str=None, metadata=None, **kwargs) -> None:
def __init__(self, *, categories=None, adult=None, color=None, image_type=None, tags=None, description=None, faces=None, objects=None, brands=None, request_id: str=None, metadata=None, **kwargs) -> None:
super(ImageAnalysis, self).__init__(**kwargs)
self.categories = categories
self.adult = adult
Expand All @@ -74,5 +78,6 @@ def __init__(self, *, categories=None, adult=None, color=None, image_type=None,
self.description = description
self.faces = faces
self.objects = objects
self.brands = brands
self.request_id = request_id
self.metadata = metadata
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
# regenerated.
# --------------------------------------------------------------------------

VERSION = "0.3.0"
VERSION = "2.0"