Using person detection in Google Colab using Google AI

Viewed 216
def detect_person(input_uri, output_uri):
    """Detects people in a video."""

    client = videointelligence.VideoIntelligenceServiceClient(credentials=service_account.Credentials.from_service_account_file(
    './key.json'))

    # Configure the request
    config = videointelligence.types.PersonDetectionConfig(
        include_bounding_boxes=True,
        include_attributes=True,
        include_pose_landmarks=True,
    )
    context = videointelligence.types.VideoContext(person_detection_config=config)

    # Start the asynchronous request
    operation = client.annotate_video(
        input_uri=input_uri,
        output_uri=output_uri,
        features=[videointelligence.enums.Feature.PERSON_DETECTION],
        video_context=context,
    )

    return operation

I then get an error when runnig:

operation = detect_person(input_uri, output_uri)

ERROR: AttributeError: module 'google.cloud.videointelligence_v1p3beta1' has no attribute 'enums' . Attempting to use Person detection in Google API but I get this error?

For some reason when I try to run the first code in Google Colab, nothing happens. I'm very new to this so I'm unsure what else I can do. Thank you so much! I am trying to follow this tutorial to create my own table tennis shot detection. https://github.com/google/making_with_ml/blob/master/sports_ai/Sports_AI_Analysis.ipynb

1 Answers

Import enums before running the code.

from google.cloud import videointelligence
from google.cloud.videointelligence import enums, types
Related