Skip to content

Commit 398a29d

Browse files
beccasaurusdanoscarmike
authored andcommitted
Access Display Names of enum fields via enum object [(#1738)](#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 39d9bff.
1 parent b7e7aab commit 398a29d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

videointelligence/samples/analyze/analyze.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import io
3131

3232
from google.cloud import videointelligence
33+
from google.cloud.videointelligence import enums
3334

3435

3536
def analyze_explicit_content(path):
@@ -44,15 +45,12 @@ def analyze_explicit_content(path):
4445
result = operation.result(timeout=90)
4546
print('\nFinished processing.')
4647

47-
likely_string = ("Unknown", "Very unlikely", "Unlikely", "Possible",
48-
"Likely", "Very likely")
49-
5048
# first result is retrieved because a single video was processed
5149
for frame in result.annotation_results[0].explicit_annotation.frames:
50+
likelihood = enums.Likelihood(frame.pornography_likelihood)
5251
frame_time = frame.time_offset.seconds + frame.time_offset.nanos / 1e9
5352
print('Time: {}s'.format(frame_time))
54-
print('\tpornography: {}'.format(
55-
likely_string[frame.pornography_likelihood]))
53+
print('\tpornography: {}'.format(likelihood.name))
5654
# [END video_analyze_explicit_content]
5755

5856

0 commit comments

Comments
 (0)