Thanks to visit codestin.com
Credit goes to github.com

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

Commit 244e21e

Browse files
yoshi-automationBenjamin E. Coe
authored andcommitted
feat: adds support for multiple regions
1 parent 828e9b5 commit 244e21e

15 files changed

Lines changed: 708 additions & 61 deletions

protos/google/cloud/vision/v1/image_annotator.proto

Lines changed: 105 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ syntax = "proto3";
1818
package google.cloud.vision.v1;
1919

2020
import "google/api/annotations.proto";
21+
import "google/api/client.proto";
2122
import "google/cloud/vision/v1/geometry.proto";
2223
import "google/cloud/vision/v1/product_search.proto";
2324
import "google/cloud/vision/v1/text_annotation.proto";
@@ -40,12 +41,25 @@ option objc_class_prefix = "GCVN";
4041
// images, such as face, landmark, logo, label, and text detection. The
4142
// ImageAnnotator service returns detected entities from the images.
4243
service ImageAnnotator {
44+
option (google.api.default_host) = "vision.googleapis.com";
45+
option (google.api.oauth_scopes) =
46+
"https://www.googleapis.com/auth/cloud-platform,"
47+
"https://www.googleapis.com/auth/cloud-vision";
48+
4349
// Run image detection and annotation for a batch of images.
4450
rpc BatchAnnotateImages(BatchAnnotateImagesRequest)
4551
returns (BatchAnnotateImagesResponse) {
4652
option (google.api.http) = {
4753
post: "/v1/images:annotate"
4854
body: "*"
55+
additional_bindings {
56+
post: "/v1/{parent=projects/*/locations/*}/images:annotate"
57+
body: "*"
58+
}
59+
additional_bindings {
60+
post: "/v1/{parent=projects/*}/images:annotate"
61+
body: "*"
62+
}
4963
};
5064
}
5165

@@ -61,6 +75,14 @@ service ImageAnnotator {
6175
option (google.api.http) = {
6276
post: "/v1/files:annotate"
6377
body: "*"
78+
additional_bindings {
79+
post: "/v1/{parent=projects/*/locations/*}/files:annotate"
80+
body: "*"
81+
}
82+
additional_bindings {
83+
post: "/v1/{parent=projects/*}/files:annotate"
84+
body: "*"
85+
}
6486
};
6587
}
6688

@@ -78,6 +100,14 @@ service ImageAnnotator {
78100
option (google.api.http) = {
79101
post: "/v1/images:asyncBatchAnnotate"
80102
body: "*"
103+
additional_bindings {
104+
post: "/v1/{parent=projects/*/locations/*}/images:asyncBatchAnnotate"
105+
body: "*"
106+
}
107+
additional_bindings {
108+
post: "/v1/{parent=projects/*}/images:asyncBatchAnnotate"
109+
body: "*"
110+
}
81111
};
82112
}
83113

@@ -92,6 +122,14 @@ service ImageAnnotator {
92122
option (google.api.http) = {
93123
post: "/v1/files:asyncBatchAnnotate"
94124
body: "*"
125+
additional_bindings {
126+
post: "/v1/{parent=projects/*/locations/*}/files:asyncBatchAnnotate"
127+
body: "*"
128+
}
129+
additional_bindings {
130+
post: "/v1/{parent=projects/*}/files:asyncBatchAnnotate"
131+
body: "*"
132+
}
95133
};
96134
}
97135
}
@@ -166,19 +204,19 @@ enum Likelihood {
166204
// Unknown likelihood.
167205
UNKNOWN = 0;
168206

169-
// It is very unlikely that the image belongs to the specified vertical.
207+
// It is very unlikely.
170208
VERY_UNLIKELY = 1;
171209

172-
// It is unlikely that the image belongs to the specified vertical.
210+
// It is unlikely.
173211
UNLIKELY = 2;
174212

175-
// It is possible that the image belongs to the specified vertical.
213+
// It is possible.
176214
POSSIBLE = 3;
177215

178-
// It is likely that the image belongs to the specified vertical.
216+
// It is likely.
179217
LIKELY = 4;
180218

181-
// It is very likely that the image belongs to the specified vertical.
219+
// It is very likely.
182220
VERY_LIKELY = 5;
183221
}
184222

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

703-
// Individual responses to images found within the file.
741+
// Individual responses to images found within the file. This field will be
742+
// empty if the `error` field is set.
704743
repeated AnnotateImageResponse responses = 2;
705744

706745
// This field gives the total number of pages in the file.
707746
int32 total_pages = 3;
747+
748+
// If set, represents the error message for the failed request. The
749+
// `responses` field will not be set in this case.
750+
google.rpc.Status error = 4;
708751
}
709752

710753
// Multiple image annotation requests are batched into a single service call.
711754
message BatchAnnotateImagesRequest {
712755
// Individual image annotation requests for this batch.
713756
repeated AnnotateImageRequest requests = 1;
757+
758+
// Optional. Target project and location to make a call.
759+
//
760+
// Format: `projects/{project-id}/locations/{location-id}`.
761+
//
762+
// If no parent is specified, a region will be chosen automatically.
763+
//
764+
// Supported location-ids:
765+
// `us`: USA country only,
766+
// `asia`: East asia areas, like Japan, Taiwan,
767+
// `eu`: The European Union.
768+
//
769+
// Example: `projects/project-A/locations/eu`.
770+
string parent = 4;
714771
}
715772

716773
// Response to a batch image annotation request.
@@ -752,6 +809,20 @@ message BatchAnnotateFilesRequest {
752809
// The list of file annotation requests. Right now we support only one
753810
// AnnotateFileRequest in BatchAnnotateFilesRequest.
754811
repeated AnnotateFileRequest requests = 1;
812+
813+
// Optional. Target project and location to make a call.
814+
//
815+
// Format: `projects/{project-id}/locations/{location-id}`.
816+
//
817+
// If no parent is specified, a region will be chosen automatically.
818+
//
819+
// Supported location-ids:
820+
// `us`: USA country only,
821+
// `asia`: East asia areas, like Japan, Taiwan,
822+
// `eu`: The European Union.
823+
//
824+
// Example: `projects/project-A/locations/eu`.
825+
string parent = 3;
755826
}
756827

757828
// A list of file annotation responses.
@@ -789,6 +860,20 @@ message AsyncBatchAnnotateImagesRequest {
789860

790861
// Required. The desired output location and metadata (e.g. format).
791862
OutputConfig output_config = 2;
863+
864+
// Optional. Target project and location to make a call.
865+
//
866+
// Format: `projects/{project-id}/locations/{location-id}`.
867+
//
868+
// If no parent is specified, a region will be chosen automatically.
869+
//
870+
// Supported location-ids:
871+
// `us`: USA country only,
872+
// `asia`: East asia areas, like Japan, Taiwan,
873+
// `eu`: The European Union.
874+
//
875+
// Example: `projects/project-A/locations/eu`.
876+
string parent = 4;
792877
}
793878

794879
// Response to an async batch image annotation request.
@@ -802,6 +887,20 @@ message AsyncBatchAnnotateImagesResponse {
802887
message AsyncBatchAnnotateFilesRequest {
803888
// Individual async file annotation requests for this batch.
804889
repeated AsyncAnnotateFileRequest requests = 1;
890+
891+
// Optional. Target project and location to make a call.
892+
//
893+
// Format: `projects/{project-id}/locations/{location-id}`.
894+
//
895+
// If no parent is specified, a region will be chosen automatically.
896+
//
897+
// Supported location-ids:
898+
// `us`: USA country only,
899+
// `asia`: East asia areas, like Japan, Taiwan,
900+
// `eu`: The European Union.
901+
//
902+
// Example: `projects/project-A/locations/eu`.
903+
string parent = 4;
805904
}
806905

807906
// Response to an async batch file annotation request.

protos/google/cloud/vision/v1/product_search.proto

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ message ProductSearchResults {
7878
string image = 3;
7979
}
8080

81+
// Prediction for what the object in the bounding box is.
82+
message ObjectAnnotation {
83+
// Object ID that should align with EntityAnnotation mid.
84+
string mid = 1;
85+
86+
// The BCP-47 language code, such as "en-US" or "sr-Latn". For more
87+
// information, see
88+
// http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
89+
string language_code = 2;
90+
91+
// Object name, expressed in its `language_code` language.
92+
string name = 3;
93+
94+
// Score of the result. Range [0, 1].
95+
float score = 4;
96+
}
97+
8198
// Information about the products similar to a single product in a query
8299
// image.
83100
message GroupedResult {
@@ -86,6 +103,9 @@ message ProductSearchResults {
86103

87104
// List of results, one for each product match.
88105
repeated Result results = 2;
106+
107+
// List of generic predictions for the object in the bounding box.
108+
repeated ObjectAnnotation object_annotations = 3;
89109
}
90110

91111
// Timestamp of the index which provided these results. Products added to the

protos/google/cloud/vision/v1/product_search_service.proto

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ syntax = "proto3";
1818
package google.cloud.vision.v1;
1919

2020
import "google/api/annotations.proto";
21+
import "google/api/client.proto";
2122
import "google/cloud/vision/v1/geometry.proto";
2223
import "google/longrunning/operations.proto";
2324
import "google/protobuf/empty.proto";
@@ -49,6 +50,11 @@ option objc_class_prefix = "GCVN";
4950
// [ReferenceImage][google.cloud.vision.v1.ReferenceImage] resources, named
5051
// `projects/*/locations/*/products/*/referenceImages/*`
5152
service ProductSearch {
53+
option (google.api.default_host) = "vision.googleapis.com";
54+
option (google.api.oauth_scopes) =
55+
"https://www.googleapis.com/auth/cloud-platform,"
56+
"https://www.googleapis.com/auth/cloud-vision";
57+
5258
// Creates and returns a new ProductSet resource.
5359
//
5460
// Possible errors:
@@ -305,6 +311,38 @@ service ProductSearch {
305311
body: "*"
306312
};
307313
}
314+
315+
// Asynchronous API to delete all Products in a ProductSet or all Products
316+
// that are in no ProductSet.
317+
//
318+
// If a Product is a member of the specified ProductSet in addition to other
319+
// ProductSets, the Product will still be deleted.
320+
//
321+
// It is recommended to not delete the specified ProductSet until after this
322+
// operation has completed. It is also recommended to not add any of the
323+
// Products involved in the batch delete to a new ProductSet while this
324+
// operation is running because those Products may still end up deleted.
325+
//
326+
// It's not possible to undo the PurgeProducts operation. Therefore, it is
327+
// recommended to keep the csv files used in ImportProductSets (if that was
328+
// how you originally built the Product Set) before starting PurgeProducts, in
329+
// case you need to re-import the data after deletion.
330+
//
331+
// If the plan is to purge all of the Products from a ProductSet and then
332+
// re-use the empty ProductSet to re-import new Products into the empty
333+
// ProductSet, you must wait until the PurgeProducts operation has finished
334+
// for that ProductSet.
335+
//
336+
// The [google.longrunning.Operation][google.longrunning.Operation] API can be
337+
// used to keep track of the progress and results of the request.
338+
// `Operation.metadata` contains `BatchOperationMetadata`. (progress)
339+
rpc PurgeProducts(PurgeProductsRequest)
340+
returns (google.longrunning.Operation) {
341+
option (google.api.http) = {
342+
post: "/v1/{parent=projects/*/locations/*}/products:purge"
343+
body: "*"
344+
};
345+
}
308346
}
309347

310348
// A Product contains ReferenceImages.
@@ -338,10 +376,8 @@ message Product {
338376

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

@@ -836,3 +876,33 @@ message BatchOperationMetadata {
836876
// set to true.
837877
google.protobuf.Timestamp end_time = 3;
838878
}
879+
880+
// Config to control which ProductSet contains the Products to be deleted.
881+
message ProductSetPurgeConfig {
882+
// The ProductSet that contains the Products to delete. If a Product is a
883+
// member of product_set_id in addition to other ProductSets, the Product will
884+
// still be deleted.
885+
string product_set_id = 1;
886+
}
887+
888+
// Request message for the `PurgeProducts` method.
889+
message PurgeProductsRequest {
890+
// The Products to delete.
891+
oneof target {
892+
// Specify which ProductSet contains the Products to be deleted.
893+
ProductSetPurgeConfig product_set_purge_config = 2;
894+
895+
// If delete_orphan_products is true, all Products that are not in any
896+
// ProductSet will be deleted.
897+
bool delete_orphan_products = 3;
898+
}
899+
900+
// The project and location in which the Products should be deleted.
901+
//
902+
// Format is `projects/PROJECT_ID/locations/LOC_ID`.
903+
string parent = 1;
904+
905+
// The default value is false. Override this value to true to actually perform
906+
// the purge.
907+
bool force = 4;
908+
}

protos/google/cloud/vision/v1/text_annotation.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ message Paragraph {
194194
// and the vertex order will still be (0, 1, 2, 3).
195195
BoundingPoly bounding_box = 2;
196196

197-
// List of words in this paragraph.
197+
// List of all words in this paragraph.
198198
repeated Word words = 3;
199199

200200
// Confidence of the OCR results for the paragraph. Range [0, 1].
@@ -250,7 +250,7 @@ message Symbol {
250250
// 2----3
251251
// | |
252252
// 1----0
253-
// and the vertice order will still be (0, 1, 2, 3).
253+
// and the vertex order will still be (0, 1, 2, 3).
254254
BoundingPoly bounding_box = 2;
255255

256256
// The actual UTF-8 representation of the symbol.

0 commit comments

Comments
 (0)