We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
**出错信 The provided code is just refference code from. Google ai studio.
import os import google.generativeai as genai
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
def upload_to_gemini(path, mime_type=None): """Uploads the given file to Gemini.
See https://ai.google.dev/gemini-api/docs/prompting_with_media """ file = genai.upload_file(path, mime_type=mime_type) print(f"Uploaded file '{file.display_name}' as: {file.uri}") return file
generation_config = { "temperature": 0.9, "top_p": 0.95, "top_k": 40, "max_output_tokens": 8192, "response_mime_type": "text/plain", }
model = genai.GenerativeModel( model_name="gemini-1.5-flash", generation_config=generation_config, )
files = [ upload_to_gemini("image_list_items_for_image1.jpeg", mime_type="image/jpeg"), upload_to_gemini("image_list_items_for_image2.jpeg", mime_type="image/jpeg"), upload_to_gemini("image_list_items_for_image3.jpeg", mime_type="image/jpeg"), ]
response = model.generate_content([ "Extract the objects in the provided image and output them in a list in alphabetical order", "Image: ", files[0], "List of Objects: - airplane\n- coffee cup\n- eiffel tower\n- globe\n- keyboard\n- mouse\n- money\n- notebook\n- passport\n- pen\n- sunglasses\n- shopping cart\n- tablet", "Image: ", files[1], "List of Objects: - gardening gloves\n- rake\n- shovel\n- plants\n- pots\n- watering can", "Image: ", files[2], "List of Objects: ", ])
print(response.text)
复现步骤
操作系统
软件左上角版本号数字
The text was updated successfully, but these errors were encountered:
No branches or pull requests
**出错信
The provided code is just refference code from. Google ai studio.
import os
import google.generativeai as genai
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
def upload_to_gemini(path, mime_type=None):
"""Uploads the given file to Gemini.
See https://ai.google.dev/gemini-api/docs/prompting_with_media
"""
file = genai.upload_file(path, mime_type=mime_type)
print(f"Uploaded file '{file.display_name}' as: {file.uri}")
return file
Create the model
generation_config = {
"temperature": 0.9,
"top_p": 0.95,
"top_k": 40,
"max_output_tokens": 8192,
"response_mime_type": "text/plain",
}
model = genai.GenerativeModel(
model_name="gemini-1.5-flash",
generation_config=generation_config,
)
TODO Make these files available on the local file system
You may need to update the file paths
files = [
upload_to_gemini("image_list_items_for_image1.jpeg", mime_type="image/jpeg"),
upload_to_gemini("image_list_items_for_image2.jpeg", mime_type="image/jpeg"),
upload_to_gemini("image_list_items_for_image3.jpeg", mime_type="image/jpeg"),
]
response = model.generate_content([
"Extract the objects in the provided image and output them in a list in alphabetical order",
"Image: ",
files[0],
"List of Objects: - airplane\n- coffee cup\n- eiffel tower\n- globe\n- keyboard\n- mouse\n- money\n- notebook\n- passport\n- pen\n- sunglasses\n- shopping cart\n- tablet",
"Image: ",
files[1],
"List of Objects: - gardening gloves\n- rake\n- shovel\n- plants\n- pots\n- watering can",
"Image: ",
files[2],
"List of Objects: ",
])
print(response.text)
复现步骤
操作系统
软件左上角版本号数字
The text was updated successfully, but these errors were encountered: