Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

markmcd
Copy link
Member

@markmcd markmcd commented Dec 13, 2023

Fixes #112

@markmcd markmcd requested a review from a team as a code owner December 13, 2023 15:08
@github-actions github-actions bot added status:awaiting review PR awaiting review from a maintainer component:python sdk Issue/PR related to Python SDK labels Dec 13, 2023
@AndrewVoirol
Copy link

import google.generativeai as genai
from pathlib import Path

genai.configure(api_key="YOUR_ACTUAL_API_KEY")

# Ensure that the model ID is correct and that you have access to it
model = genai.GenerativeModel('gemini-pro-vision')

# Read the image as binary data
image_path = Path('image.png')
image_data = image_path.read_bytes()

prompt = "Give me a recipe for this:"
contents = {
    'parts': [
        {'mime_type': 'image/png', 'data': image_data},
        {'text': prompt}
    ]
}

# Send the prompt and image data to the model
response = model.generate_content(contents=contents)

# Print the result
print(response.text)

@MarkDaoust MarkDaoust merged commit c6688b7 into main Dec 14, 2023
@github-actions github-actions bot removed the status:awaiting review PR awaiting review from a maintainer label Dec 14, 2023
@markmcd markmcd deleted the markmcd-patch-1 branch December 14, 2023 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:python sdk Issue/PR related to Python SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Readme for new Gemini Code Samples on Recipie to be updated to accept Image
3 participants