From eb6f109b04e645aabbbbe283c9d767b0bf386398 Mon Sep 17 00:00:00 2001 From: Rebecca Taylor Date: Mon, 15 Oct 2018 13:53:04 -0700 Subject: [PATCH] Access Display Names of enum fields via enum object [(#1738)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1738) * Get display name of enums using IntEnum Requires updating google-cloud-language to 1.1.0 * Add note about gs://demomaker for video test files * Get display name of enums using IntEnum * Get display name of enums using IntEnum * Revert "Add note about gs://demomaker for video test files" This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62. --- .../samples/analyze/analyze.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/google-cloud-videointelligence/samples/analyze/analyze.py b/packages/google-cloud-videointelligence/samples/analyze/analyze.py index 1905c0e712f7..5a13d01c823e 100644 --- a/packages/google-cloud-videointelligence/samples/analyze/analyze.py +++ b/packages/google-cloud-videointelligence/samples/analyze/analyze.py @@ -30,6 +30,7 @@ import io from google.cloud import videointelligence +from google.cloud.videointelligence import enums def analyze_explicit_content(path): @@ -44,15 +45,12 @@ def analyze_explicit_content(path): result = operation.result(timeout=90) print('\nFinished processing.') - likely_string = ("Unknown", "Very unlikely", "Unlikely", "Possible", - "Likely", "Very likely") - # first result is retrieved because a single video was processed for frame in result.annotation_results[0].explicit_annotation.frames: + likelihood = enums.Likelihood(frame.pornography_likelihood) frame_time = frame.time_offset.seconds + frame.time_offset.nanos / 1e9 print('Time: {}s'.format(frame_time)) - print('\tpornography: {}'.format( - likely_string[frame.pornography_likelihood])) + print('\tpornography: {}'.format(likelihood.name)) # [END video_analyze_explicit_content]