-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertexAI_Bildanalyse.py
More file actions
32 lines (26 loc) · 864 Bytes
/
VertexAI_Bildanalyse.py
File metadata and controls
32 lines (26 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import vertexai
from vertexai.generative_models import GenerativeModel, Part
def generate_text(project_id: str, location: str) -> str:
# Initialize Vertex AI
vertexai.init(project=project_id, location=location)
# Load the model
multimodal_model = GenerativeModel("gemini-1.0-pro-vision")
# Query the model
response = multimodal_model.generate_content(
[
# Add an example image
Part.from_uri(
"gs://generativeai-downloads/images/scones.jpg",
mime_type="image/jpeg"
),
# Add an example query
"what is shown in this image?"
]
)
return response.text
# Important: Variable declaration
project_id = "MeineBildanalyse1"
location = "us-east4"
# Call the Function
response = generate_text(project_id, location)
print(response)