Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Commit

Permalink
feat: adds support for multiple regions
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and bcoe committed Aug 19, 2019
1 parent 828e9b5 commit 244e21e
Show file tree
Hide file tree
Showing 15 changed files with 708 additions and 61 deletions.
111 changes: 105 additions & 6 deletions protos/google/cloud/vision/v1/image_annotator.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ syntax = "proto3";
package google.cloud.vision.v1;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/cloud/vision/v1/geometry.proto";
import "google/cloud/vision/v1/product_search.proto";
import "google/cloud/vision/v1/text_annotation.proto";
Expand All @@ -40,12 +41,25 @@ option objc_class_prefix = "GCVN";
// images, such as face, landmark, logo, label, and text detection. The
// ImageAnnotator service returns detected entities from the images.
service ImageAnnotator {
option (google.api.default_host) = "vision.googleapis.com";
option (google.api.oauth_scopes) =
"https://www.googleapis.com/auth/cloud-platform,"
"https://www.googleapis.com/auth/cloud-vision";

// Run image detection and annotation for a batch of images.
rpc BatchAnnotateImages(BatchAnnotateImagesRequest)
returns (BatchAnnotateImagesResponse) {
option (google.api.http) = {
post: "/v1/images:annotate"
body: "*"
additional_bindings {
post: "/v1/{parent=projects/*/locations/*}/images:annotate"
body: "*"
}
additional_bindings {
post: "/v1/{parent=projects/*}/images:annotate"
body: "*"
}
};
}

Expand All @@ -61,6 +75,14 @@ service ImageAnnotator {
option (google.api.http) = {
post: "/v1/files:annotate"
body: "*"
additional_bindings {
post: "/v1/{parent=projects/*/locations/*}/files:annotate"
body: "*"
}
additional_bindings {
post: "/v1/{parent=projects/*}/files:annotate"
body: "*"
}
};
}

Expand All @@ -78,6 +100,14 @@ service ImageAnnotator {
option (google.api.http) = {
post: "/v1/images:asyncBatchAnnotate"
body: "*"
additional_bindings {
post: "/v1/{parent=projects/*/locations/*}/images:asyncBatchAnnotate"
body: "*"
}
additional_bindings {
post: "/v1/{parent=projects/*}/images:asyncBatchAnnotate"
body: "*"
}
};
}

Expand All @@ -92,6 +122,14 @@ service ImageAnnotator {
option (google.api.http) = {
post: "/v1/files:asyncBatchAnnotate"
body: "*"
additional_bindings {
post: "/v1/{parent=projects/*/locations/*}/files:asyncBatchAnnotate"
body: "*"
}
additional_bindings {
post: "/v1/{parent=projects/*}/files:asyncBatchAnnotate"
body: "*"
}
};
}
}
Expand Down Expand Up @@ -166,19 +204,19 @@ enum Likelihood {
// Unknown likelihood.
UNKNOWN = 0;

// It is very unlikely that the image belongs to the specified vertical.
// It is very unlikely.
VERY_UNLIKELY = 1;

// It is unlikely that the image belongs to the specified vertical.
// It is unlikely.
UNLIKELY = 2;

// It is possible that the image belongs to the specified vertical.
// It is possible.
POSSIBLE = 3;

// It is likely that the image belongs to the specified vertical.
// It is likely.
LIKELY = 4;

// It is very likely that the image belongs to the specified vertical.
// It is very likely.
VERY_LIKELY = 5;
}

Expand Down Expand Up @@ -700,17 +738,36 @@ message AnnotateFileResponse {
// Information about the file for which this response is generated.
InputConfig input_config = 1;

// Individual responses to images found within the file.
// Individual responses to images found within the file. This field will be
// empty if the `error` field is set.
repeated AnnotateImageResponse responses = 2;

// This field gives the total number of pages in the file.
int32 total_pages = 3;

// If set, represents the error message for the failed request. The
// `responses` field will not be set in this case.
google.rpc.Status error = 4;
}

// Multiple image annotation requests are batched into a single service call.
message BatchAnnotateImagesRequest {
// Individual image annotation requests for this batch.
repeated AnnotateImageRequest requests = 1;

// Optional. Target project and location to make a call.
//
// Format: `projects/{project-id}/locations/{location-id}`.
//
// If no parent is specified, a region will be chosen automatically.
//
// Supported location-ids:
// `us`: USA country only,
// `asia`: East asia areas, like Japan, Taiwan,
// `eu`: The European Union.
//
// Example: `projects/project-A/locations/eu`.
string parent = 4;
}

// Response to a batch image annotation request.
Expand Down Expand Up @@ -752,6 +809,20 @@ message BatchAnnotateFilesRequest {
// The list of file annotation requests. Right now we support only one
// AnnotateFileRequest in BatchAnnotateFilesRequest.
repeated AnnotateFileRequest requests = 1;

// Optional. Target project and location to make a call.
//
// Format: `projects/{project-id}/locations/{location-id}`.
//
// If no parent is specified, a region will be chosen automatically.
//
// Supported location-ids:
// `us`: USA country only,
// `asia`: East asia areas, like Japan, Taiwan,
// `eu`: The European Union.
//
// Example: `projects/project-A/locations/eu`.
string parent = 3;
}

// A list of file annotation responses.
Expand Down Expand Up @@ -789,6 +860,20 @@ message AsyncBatchAnnotateImagesRequest {

// Required. The desired output location and metadata (e.g. format).
OutputConfig output_config = 2;

// Optional. Target project and location to make a call.
//
// Format: `projects/{project-id}/locations/{location-id}`.
//
// If no parent is specified, a region will be chosen automatically.
//
// Supported location-ids:
// `us`: USA country only,
// `asia`: East asia areas, like Japan, Taiwan,
// `eu`: The European Union.
//
// Example: `projects/project-A/locations/eu`.
string parent = 4;
}

// Response to an async batch image annotation request.
Expand All @@ -802,6 +887,20 @@ message AsyncBatchAnnotateImagesResponse {
message AsyncBatchAnnotateFilesRequest {
// Individual async file annotation requests for this batch.
repeated AsyncAnnotateFileRequest requests = 1;

// Optional. Target project and location to make a call.
//
// Format: `projects/{project-id}/locations/{location-id}`.
//
// If no parent is specified, a region will be chosen automatically.
//
// Supported location-ids:
// `us`: USA country only,
// `asia`: East asia areas, like Japan, Taiwan,
// `eu`: The European Union.
//
// Example: `projects/project-A/locations/eu`.
string parent = 4;
}

// Response to an async batch file annotation request.
Expand Down
20 changes: 20 additions & 0 deletions protos/google/cloud/vision/v1/product_search.proto
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ message ProductSearchResults {
string image = 3;
}

// Prediction for what the object in the bounding box is.
message ObjectAnnotation {
// Object ID that should align with EntityAnnotation mid.
string mid = 1;

// The BCP-47 language code, such as "en-US" or "sr-Latn". For more
// information, see
// http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
string language_code = 2;

// Object name, expressed in its `language_code` language.
string name = 3;

// Score of the result. Range [0, 1].
float score = 4;
}

// Information about the products similar to a single product in a query
// image.
message GroupedResult {
Expand All @@ -86,6 +103,9 @@ message ProductSearchResults {

// List of results, one for each product match.
repeated Result results = 2;

// List of generic predictions for the object in the bounding box.
repeated ObjectAnnotation object_annotations = 3;
}

// Timestamp of the index which provided these results. Products added to the
Expand Down
80 changes: 75 additions & 5 deletions protos/google/cloud/vision/v1/product_search_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ syntax = "proto3";
package google.cloud.vision.v1;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/cloud/vision/v1/geometry.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/empty.proto";
Expand Down Expand Up @@ -49,6 +50,11 @@ option objc_class_prefix = "GCVN";
// [ReferenceImage][google.cloud.vision.v1.ReferenceImage] resources, named
// `projects/*/locations/*/products/*/referenceImages/*`
service ProductSearch {
option (google.api.default_host) = "vision.googleapis.com";
option (google.api.oauth_scopes) =
"https://www.googleapis.com/auth/cloud-platform,"
"https://www.googleapis.com/auth/cloud-vision";

// Creates and returns a new ProductSet resource.
//
// Possible errors:
Expand Down Expand Up @@ -305,6 +311,38 @@ service ProductSearch {
body: "*"
};
}

// 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][google.longrunning.Operation] API can be
// used to keep track of the progress and results of the request.
// `Operation.metadata` contains `BatchOperationMetadata`. (progress)
rpc PurgeProducts(PurgeProductsRequest)
returns (google.longrunning.Operation) {
option (google.api.http) = {
post: "/v1/{parent=projects/*/locations/*}/products:purge"
body: "*"
};
}
}

// A Product contains ReferenceImages.
Expand Down Expand Up @@ -338,10 +376,8 @@ message Product {

// The category for the product identified by the reference image. This should
// be either "homegoods-v2", "apparel-v2", or "toys-v2". The legacy categories
// "homegoods", "apparel", and "toys" are still supported but will be
// deprecated. For new products, please use "homegoods-v2", "apparel-v2", or
// "toys-v2" for better product search accuracy. It is recommended to migrate
// existing products to these categories as well.
// "homegoods", "apparel", and "toys" are still supported, but these should
// not be used for new products.
//
// This field is immutable.
string product_category = 4;
Expand All @@ -354,7 +390,11 @@ message Product {
// to be supported soon.
//
// Multiple values can be assigned to the same key. One product may have up to
// 100 product_labels.
// 500 product_labels.
//
// Notice that the total number of distinct product_labels over all products
// in one ProductSet cannot exceed 1M, otherwise the product search pipeline
// will refuse to work for that ProductSet.
repeated KeyValue product_labels = 5;
}

Expand Down Expand Up @@ -836,3 +876,33 @@ message BatchOperationMetadata {
// set to true.
google.protobuf.Timestamp end_time = 3;
}

// Config to control which ProductSet contains the Products to be deleted.
message ProductSetPurgeConfig {
// The ProductSet that contains the Products to delete. If a Product is a
// member of product_set_id in addition to other ProductSets, the Product will
// still be deleted.
string product_set_id = 1;
}

// Request message for the `PurgeProducts` method.
message PurgeProductsRequest {
// The Products to delete.
oneof target {
// Specify which ProductSet contains the Products to be deleted.
ProductSetPurgeConfig product_set_purge_config = 2;

// If delete_orphan_products is true, all Products that are not in any
// ProductSet will be deleted.
bool delete_orphan_products = 3;
}

// The project and location in which the Products should be deleted.
//
// Format is `projects/PROJECT_ID/locations/LOC_ID`.
string parent = 1;

// The default value is false. Override this value to true to actually perform
// the purge.
bool force = 4;
}
4 changes: 2 additions & 2 deletions protos/google/cloud/vision/v1/text_annotation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ message Paragraph {
// and the vertex order will still be (0, 1, 2, 3).
BoundingPoly bounding_box = 2;

// List of words in this paragraph.
// List of all words in this paragraph.
repeated Word words = 3;

// Confidence of the OCR results for the paragraph. Range [0, 1].
Expand Down Expand Up @@ -250,7 +250,7 @@ message Symbol {
// 2----3
// | |
// 1----0
// and the vertice order will still be (0, 1, 2, 3).
// and the vertex order will still be (0, 1, 2, 3).
BoundingPoly bounding_box = 2;

// The actual UTF-8 representation of the symbol.
Expand Down
Loading

0 comments on commit 244e21e

Please sign in to comment.