0

Using the following code on JupyterLab in order to run Google Video Intelligence Package:

from google.cloud import videointelligence
import os

client = videointelligence.VideoIntelligenceServiceClient('VidIntelligence.JSON')
job = client.annotate_video(
    input_uri='gs://vidintelligencebucket/The Simpsons - Monopoly Night.mp4',
    features=['LABEL_DETECTION', 'SHOT_CHANGE_DETECTION'],
)
result = job.result()

When I run it, the following error appears:

AttributeError: 'str' object has no attribute 'annotate_video'

Any suggestions?

Zoe
  • 27,060
  • 21
  • 118
  • 148
jb6ei
  • 41
  • 1
  • Try to print that `client` variable. Would there be some error message waiting for you. That code is basicly copy&paste from example, so it should work. – ex4 Apr 26 '20 at 07:50

1 Answers1

0

This happens because as ex4 pointed out variable client is of type str and just contains an error message.

The error occurs because you are trying to authenticate in a non correct way. The argument passed to the credentials parameter of the client cannot be of type str but should be a Credentials object as stated in the client description.

You can check this overview for all the valid ways to authenticate the client.

Since you have a json file with the credentials you just need to point to it using an environment variable named GOOGLE_APPLICATION_CREDENTIALS:

$ export GOOGLE_APPLICATION_CREDENTIALS="/path/to/VidIntelligence.json"

Then you will be able to initialize your client without passing any arguments:

client = videointelligence.VideoIntelligenceServiceClient()

Hope that this helps!

itroulli
  • 2,044
  • 1
  • 10
  • 21