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

feat(vision): add celebrity recognition support; add object annotation support; add 'purge_products' method (all v1p4beta1) (via synth) #9613

Merged
merged 1 commit into from
Nov 6, 2019
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
10 changes: 5 additions & 5 deletions vision/google/cloud/vision_v1p4beta1/gapic/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class Likelihood(enum.IntEnum):

Attributes:
UNKNOWN (int): Unknown likelihood.
VERY_UNLIKELY (int): It is very unlikely that the image belongs to the specified vertical.
UNLIKELY (int): It is unlikely that the image belongs to the specified vertical.
POSSIBLE (int): It is possible that the image belongs to the specified vertical.
LIKELY (int): It is likely that the image belongs to the specified vertical.
VERY_LIKELY (int): It is very likely that the image belongs to the specified vertical.
VERY_UNLIKELY (int): It is very unlikely.
UNLIKELY (int): It is unlikely.
POSSIBLE (int): It is possible.
LIKELY (int): It is likely.
VERY_LIKELY (int): It is very likely.
"""

UNKNOWN = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ def batch_annotate_files(
>>> response = client.batch_annotate_files(requests)

Args:
requests (list[Union[dict, ~google.cloud.vision_v1p4beta1.types.AnnotateFileRequest]]): The list of file annotation requests. Right now we support only one
AnnotateFileRequest in BatchAnnotateFilesRequest.
requests (list[Union[dict, ~google.cloud.vision_v1p4beta1.types.AnnotateFileRequest]]): Required. The list of file annotation requests. Right now we support only
one AnnotateFileRequest in BatchAnnotateFilesRequest.

If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.vision_v1p4beta1.types.AnnotateFileRequest`
Expand Down Expand Up @@ -363,7 +363,7 @@ def async_batch_annotate_images(
>>> metadata = response.metadata()

Args:
requests (list[Union[dict, ~google.cloud.vision_v1p4beta1.types.AnnotateImageRequest]]): Individual image annotation requests for this batch.
requests (list[Union[dict, ~google.cloud.vision_v1p4beta1.types.AnnotateImageRequest]]): Required. Individual image annotation requests for this batch.

If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.vision_v1p4beta1.types.AnnotateImageRequest`
Expand Down Expand Up @@ -451,7 +451,7 @@ def async_batch_annotate_files(
>>> metadata = response.metadata()

Args:
requests (list[Union[dict, ~google.cloud.vision_v1p4beta1.types.AsyncAnnotateFileRequest]]): Individual async file annotation requests for this batch.
requests (list[Union[dict, ~google.cloud.vision_v1p4beta1.types.AsyncAnnotateFileRequest]]): Required. Individual async file annotation requests for this batch.

If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.vision_v1p4beta1.types.AsyncAnnotateFileRequest`
Expand Down
195 changes: 150 additions & 45 deletions vision/google/cloud/vision_v1p4beta1/gapic/product_search_client.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"PurgeProducts": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,6 @@ def delete_product_set(self):

The actual image files are not deleted from Google Cloud Storage.

Possible errors:

- Returns NOT\_FOUND if the ProductSet does not exist.

Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
Expand Down Expand Up @@ -302,13 +298,9 @@ def delete_product(self):

Permanently deletes a product and its reference images.

Metadata of the product and all its images will be deleted right away,
but search queries against ProductSets containing the product may still
work until all related caches are refreshed.

Possible errors:

- Returns NOT\_FOUND if the product does not exist.
Metadata of the product and all its images will be deleted right away, but
search queries against ProductSets containing the product may still work
until all related caches are refreshed.

Returns:
Callable: A callable which accepts the appropriate
Expand Down Expand Up @@ -357,15 +349,11 @@ def delete_reference_image(self):
Permanently deletes a reference image.

The image metadata will be deleted right away, but search queries
against ProductSets containing the image may still work until all
related caches are refreshed.
against ProductSets containing the image may still work until all related
caches are refreshed.

The actual image files are not deleted from Google Cloud Storage.

Possible errors:

- Returns NOT\_FOUND if the reference image does not exist.

Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
Expand Down Expand Up @@ -435,10 +423,6 @@ def remove_product_from_product_set(self):

Removes a Product from the specified ProductSet.

Possible errors:

- Returns NOT\_FOUND If the Product is not found under the ProductSet.

Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
Expand Down Expand Up @@ -488,3 +472,39 @@ def import_product_sets(self):
deserialized response object.
"""
return self._stubs["product_search_stub"].ImportProductSets

@property
def purge_products(self):
"""Return the gRPC stub for :meth:`ProductSearchClient.purge_products`.

Asynchronous API to delete all Products in a ProductSet or all Products
that are in no ProductSet.

If a Product is a member of the specified ProductSet in addition to
other ProductSets, the Product will still be deleted.

It is recommended to not delete the specified ProductSet until after
this operation has completed. It is also recommended to not add any of
the Products involved in the batch delete to a new ProductSet while this
operation is running because those Products may still end up deleted.

It's not possible to undo the PurgeProducts operation. Therefore, it is
recommended to keep the csv files used in ImportProductSets (if that was
how you originally built the Product Set) before starting PurgeProducts,
in case you need to re-import the data after deletion.

If the plan is to purge all of the Products from a ProductSet and then
re-use the empty ProductSet to re-import new Products into the empty
ProductSet, you must wait until the PurgeProducts operation has finished
for that ProductSet.

The ``google.longrunning.Operation`` API can be used to keep track of
the progress and results of the request. ``Operation.metadata`` contains
``BatchOperationMetadata``. (progress)

Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["product_search_stub"].PurgeProducts
61 changes: 61 additions & 0 deletions vision/google/cloud/vision_v1p4beta1/proto/face.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

syntax = "proto3";

package google.cloud.vision.v1p4beta1;

import "google/api/annotations.proto";
import "google/cloud/vision/v1p4beta1/geometry.proto";

option cc_enable_arenas = true;
option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision";
option java_multiple_files = true;
option java_outer_classname = "CelebrityProto";
option java_package = "com.google.cloud.vision.v1p4beta1";
option objc_class_prefix = "GCVN";

// Parameters for a celebrity recognition request.
message FaceRecognitionParams {
// The resource names for one or more
// [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]s. A celebrity
// set is preloaded and can be specified as "builtin/default". If this is
// specified, the algorithm will try to match the faces detected in the input
// image to the Celebrities in the CelebritySets.
repeated string celebrity_set = 1;
}

// A Celebrity is a group of Faces with an identity.
message Celebrity {
// The resource name of the preloaded Celebrity. Has the format
// `builtin/{mid}`.
string name = 1;

// The Celebrity's display name.
string display_name = 2;

// The Celebrity's description.
string description = 3;
}

// Information about a face's identity.
message FaceRecognitionResult {
// The [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] that this face was
// matched to.
Celebrity celebrity = 1;

// Recognition confidence. Range [0, 1].
float confidence = 2;
}
Loading