From d7ddff8b621dfe09e331f06ed6ce0ede8eafa10f Mon Sep 17 00:00:00 2001 From: Cameron Zahedi Date: Tue, 10 Mar 2020 11:36:56 -0600 Subject: [PATCH 1/3] Clarifying comment for batch requests --- .../cloud-client/detect/vision_async_batch_annotate_images.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vision/cloud-client/detect/vision_async_batch_annotate_images.py b/vision/cloud-client/detect/vision_async_batch_annotate_images.py index bdbf41e10f7..6d9dbad1456 100644 --- a/vision/cloud-client/detect/vision_async_batch_annotate_images.py +++ b/vision/cloud-client/detect/vision_async_batch_annotate_images.py @@ -31,6 +31,10 @@ def sample_async_batch_annotate_images( {"type": enums.Feature.Type.LABEL_DETECTION}, {"type": enums.Feature.Type.IMAGE_PROPERTIES}, ] + + # Each requests element corresponds to a single image. To annotate more + # images, create a request element for each image and add it to + # the array of requests requests = [{"image": image, "features": features}] gcs_destination = {"uri": output_uri} From 9235fb445774ea32e108410bc1e9b20e054b125d Mon Sep 17 00:00:00 2001 From: Cameron Zahedi Date: Tue, 10 Mar 2020 11:50:40 -0600 Subject: [PATCH 2/3] vision: fixing linter for batch --- .../detect/vision_async_batch_annotate_images.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vision/cloud-client/detect/vision_async_batch_annotate_images.py b/vision/cloud-client/detect/vision_async_batch_annotate_images.py index 6d9dbad1456..c0295888330 100644 --- a/vision/cloud-client/detect/vision_async_batch_annotate_images.py +++ b/vision/cloud-client/detect/vision_async_batch_annotate_images.py @@ -31,16 +31,17 @@ def sample_async_batch_annotate_images( {"type": enums.Feature.Type.LABEL_DETECTION}, {"type": enums.Feature.Type.IMAGE_PROPERTIES}, ] - + # Each requests element corresponds to a single image. To annotate more # images, create a request element for each image and add it to - # the array of requests + # the array of requests requests = [{"image": image, "features": features}] gcs_destination = {"uri": output_uri} # The max number of responses to output in each JSON file batch_size = 2 - output_config = {"gcs_destination": gcs_destination, "batch_size": batch_size} + output_config = {"gcs_destination": gcs_destination, + "batch_size": batch_size} operation = client.async_batch_annotate_images(requests, output_config) From c574730eb9b354ebd396df8593b2af0c100313b9 Mon Sep 17 00:00:00 2001 From: Cameron Zahedi Date: Thu, 12 Mar 2020 12:54:55 -0600 Subject: [PATCH 3/3] DO NOT MERGE vision: logo detection GA samples --- video/cloud-client/analyze/requirements.txt | 2 +- ...{video_detect_logo_beta.py => video_detect_logo.py} | 10 +++++----- ...etect_logo_gcs_beta.py => video_detect_logo_gcs.py} | 10 +++++----- ..._gcs_beta_test.py => video_detect_logo_gcs_test.py} | 4 ++-- ...ect_logo_beta_test.py => video_detect_logo_test.py} | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) rename video/cloud-client/analyze/{video_detect_logo_beta.py => video_detect_logo.py} (95%) rename video/cloud-client/analyze/{video_detect_logo_gcs_beta.py => video_detect_logo_gcs.py} (94%) rename video/cloud-client/analyze/{video_detect_logo_gcs_beta_test.py => video_detect_logo_gcs_test.py} (89%) rename video/cloud-client/analyze/{video_detect_logo_beta_test.py => video_detect_logo_test.py} (89%) diff --git a/video/cloud-client/analyze/requirements.txt b/video/cloud-client/analyze/requirements.txt index 9958046a7db..8a9815cc32e 100644 --- a/video/cloud-client/analyze/requirements.txt +++ b/video/cloud-client/analyze/requirements.txt @@ -1,2 +1,2 @@ -google-cloud-videointelligence==1.13.0 +google-cloud-videointelligence==1.14.0 google-cloud-storage==1.26.0 diff --git a/video/cloud-client/analyze/video_detect_logo_beta.py b/video/cloud-client/analyze/video_detect_logo.py similarity index 95% rename from video/cloud-client/analyze/video_detect_logo_beta.py rename to video/cloud-client/analyze/video_detect_logo.py index 3ec90bd242d..3108cd3986b 100644 --- a/video/cloud-client/analyze/video_detect_logo_beta.py +++ b/video/cloud-client/analyze/video_detect_logo.py @@ -14,16 +14,16 @@ import io -# [START video_detect_logo_beta] +# [START video_detect_logo] -from google.cloud import videointelligence_v1p3beta1 -from google.cloud.videointelligence_v1p3beta1 import enums +from google.cloud import videointelligence +from google.cloud.videointelligence import enums def sample_annotate_video(local_file_path="resources/googlework_tiny.mp4"): """Performs asynchronous video annotation for logo recognition on a local file.""" - client = videointelligence_v1p3beta1.VideoIntelligenceServiceClient() + client = videointelligence.VideoIntelligenceServiceClient() with io.open(local_file_path, "rb") as f: input_content = f.read() @@ -104,4 +104,4 @@ def sample_annotate_video(local_file_path="resources/googlework_tiny.mp4"): ) -# [END video_detect_logo_beta] +# [END video_detect_logo] diff --git a/video/cloud-client/analyze/video_detect_logo_gcs_beta.py b/video/cloud-client/analyze/video_detect_logo_gcs.py similarity index 94% rename from video/cloud-client/analyze/video_detect_logo_gcs_beta.py rename to video/cloud-client/analyze/video_detect_logo_gcs.py index 47ccddd8923..2f70e4e1c68 100644 --- a/video/cloud-client/analyze/video_detect_logo_gcs_beta.py +++ b/video/cloud-client/analyze/video_detect_logo_gcs.py @@ -12,17 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START video_detect_logo_gcs_beta] +# [START video_detect_logo_gcs] -from google.cloud import videointelligence_v1p3beta1 -from google.cloud.videointelligence_v1p3beta1 import enums +from google.cloud import videointelligence +from google.cloud.videointelligence import enums def sample_annotate_video( input_uri="gs://cloud-samples-data/video/googlework_tiny.mp4", ): - client = videointelligence_v1p3beta1.VideoIntelligenceServiceClient() + client = videointelligence.VideoIntelligenceServiceClient() features_element = enums.Feature.LOGO_RECOGNITION features = [features_element] @@ -101,4 +101,4 @@ def sample_annotate_video( ) -# [END video_detect_logo_gcs_beta] +# [END video_detect_logo_gcs] diff --git a/video/cloud-client/analyze/video_detect_logo_gcs_beta_test.py b/video/cloud-client/analyze/video_detect_logo_gcs_test.py similarity index 89% rename from video/cloud-client/analyze/video_detect_logo_gcs_beta_test.py rename to video/cloud-client/analyze/video_detect_logo_gcs_test.py index 7c6c6530327..3b2bee8edd6 100644 --- a/video/cloud-client/analyze/video_detect_logo_gcs_beta_test.py +++ b/video/cloud-client/analyze/video_detect_logo_gcs_test.py @@ -14,7 +14,7 @@ import os -import video_detect_logo_gcs_beta +import video_detect_logo_gcs RESOURCES = os.path.join(os.path.dirname(__file__), "resources") @@ -22,7 +22,7 @@ def test_sample_annotate_video(capsys): input_uri = "gs://cloud-samples-data/video/googlework_tiny.mp4" - video_detect_logo_gcs_beta.sample_annotate_video(input_uri=input_uri) + video_detect_logo_gcs.sample_annotate_video(input_uri=input_uri) out, _ = capsys.readouterr() diff --git a/video/cloud-client/analyze/video_detect_logo_beta_test.py b/video/cloud-client/analyze/video_detect_logo_test.py similarity index 89% rename from video/cloud-client/analyze/video_detect_logo_beta_test.py rename to video/cloud-client/analyze/video_detect_logo_test.py index 1605fc499c9..9a73ddf8ad3 100644 --- a/video/cloud-client/analyze/video_detect_logo_beta_test.py +++ b/video/cloud-client/analyze/video_detect_logo_test.py @@ -14,7 +14,7 @@ import os -import video_detect_logo_beta +import video_detect_logo RESOURCES = os.path.join(os.path.dirname(__file__), "resources") @@ -22,7 +22,7 @@ def test_sample_annotate_video(capsys): local_file_path = os.path.join(RESOURCES, "googlework_tiny.mp4") - video_detect_logo_beta.sample_annotate_video(local_file_path=local_file_path) + video_detect_logo.sample_annotate_video(local_file_path=local_file_path) out, _ = capsys.readouterr()