ihgumilar / multimodal-gemini

0 stars 0 forks source link

Function to extract video #1

Open ihgumilar opened 10 months ago

ihgumilar commented 10 months ago

See this tutorial

Init gemini for text, image, chat for Video still has an issue, which requires application default credentials

ihgumilar commented 10 months ago

See this guideline for Application Default Credentials issue

For the following error : `--------------------------------------------------------------------------- DefaultCredentialsError Traceback (most recent call last) Cell In[21], line 10 4 gemini_pro_vision_model = GenerativeModel("gemini-pro-vision") 5 response = gemini_pro_vision_model.generate_content([ 6 "Tell me the objective of the research as discussed in the video? ", 7 generative_models.Part.from_uri("https://drive.google.com/file/d/1wCWeGPhvOIkWxFAGlHvbA-Dn5Yq45B2e/view?usp=sharing", mime_type="video/mp4"), 8 ], stream=True) ---> 10 for chunk in response : 11 print(chunk.text)

File ~/miniconda3/envs/gemini/lib/python3.9/site-packages/vertexai/generative_models/_generative_models.py:518, in _GenerativeModel._generate_content_streaming(self, contents, generation_config, safety_settings, tools) 495 """Generates content. 496 497 Args: (...) 510 A stream of GenerationResponse objects 511 """ 512 request = self._prepare_request( 513 contents=contents, 514 generation_config=generation_config, 515 safety_settings=safety_settings, 516 tools=tools, 517 ) --> 518 response_stream = self._prediction_client.stream_generate_content( 519 request=request 520 ) 521 for chunk in response_stream: 522 yield self._parse_response(chunk)

File ~/miniconda3/envs/gemini/lib/python3.9/site-packages/vertexai/generative_models/_generative_models.py:180, in _GenerativeModel._prediction_client(self) 175 @property 176 def _prediction_client(self) -> prediction_service.PredictionServiceClient: 177 # Switch to @functools.cached_property once its available. 178 if not getattr(self, "_prediction_client_value", None): 179 self._prediction_client_value = ( --> 180 aiplatform_initializer.global_config.create_client( 181 client_class=prediction_service.PredictionServiceClient, 182 prediction_client=True, 183 ) 184 ) 185 return self._prediction_client_value

File ~/miniconda3/envs/gemini/lib/python3.9/site-packages/google/cloud/aiplatform/initializer.py:476, in _Config.create_client(self, client_class, credentials, location_override, prediction_client, api_base_path_override, api_path_override, appended_user_agent, appended_gapic_version) 468 user_agent = f"{user_agent} {' '.join(appended_user_agent)}" 470 client_info = gapic_v1.client_info.ClientInfo( 471 gapic_version=gapic_version, 472 user_agent=user_agent, 473 ) 475 kwargs = { --> 476 "credentials": credentials or self.credentials, 477 "client_options": self.get_client_options( 478 location_override=location_override, 479 prediction_client=prediction_client, 480 api_base_path_override=api_base_path_override, 481 api_path_override=api_path_override, 482 ), 483 "client_info": client_info, 484 } 486 return client_class(**kwargs)

File ~/miniconda3/envs/gemini/lib/python3.9/site-packages/google/cloud/aiplatform/initializer.py:320, in _Config.credentials(self) 318 logging_warning_filter = utils.LoggingFilter(logging.WARNING) 319 logger.addFilter(logging_warning_filter) --> 320 self._set_project_as_env_var_or_google_auth_default() 321 credentials = self._credentials 322 logger.removeFilter(logging_warning_filter)

File ~/miniconda3/envs/gemini/lib/python3.9/site-packages/google/cloud/aiplatform/initializer.py:95, in _Config._set_project_as_env_var_or_google_auth_default(self) 92 self._project = project 94 if not self.credentials: ---> 95 credentials, = google.auth.default() 96 self._credentials = credentials

File ~/miniconda3/envs/gemini/lib/python3.9/site-packages/google/auth/_default.py:691, in default(scopes, request, quota_project_id, default_scopes) 683 _LOGGER.warning( 684 "No project ID could be determined. Consider running " 685 "gcloud config set project or setting the %s " 686 "environment variable", 687 environment_vars.PROJECT, 688 ) 689 return credentials, effective_project_id --> 691 raise exceptions.DefaultCredentialsError(_CLOUD_SDK_MISSING_CREDENTIALS)

DefaultCredentialsError: Your default credentials were not found. To set up Application Default Credentials, see https://cloud.google.com/docs/authentication/external/set-up-adc for more information.`