-
Notifications
You must be signed in to change notification settings - Fork 6.5k
feat(genai): Add new sample for image gen #13336
New issue
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
base: main
Are you sure you want to change the base?
Conversation
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @katiemn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request adds a new sample, imggen_with_txt.py
, demonstrating image generation using the Gen AI SDK. The sample generates an image based on a text prompt and uploads it to a Google Cloud Storage bucket. The pull request also includes a test case for the new sample in test_image_generation.py
.
Highlights
- New Sample: Introduces
imggen_with_txt.py
, a new sample for generating images from text prompts using the Gen AI SDK. - Image Generation: The sample uses the
imagen-3.0-generate-002
model to generate an image of a dog reading a newspaper. - Testing: Adds a test case to
test_image_generation.py
to verify the functionality of the new image generation sample.
Changelog
- genai/image_generation/imggen_with_txt.py
- Created a new file
imggen_with_txt.py
containing the image generation sample code. - The sample uses the
google.genai
library to generate an image based on a text prompt. - The generated image is uploaded to a Google Cloud Storage bucket specified by
output_gcs_uri
. - The sample includes a
TODO
comment for the developer to update theoutput_gcs_uri
with their own bucket.
- Created a new file
- genai/image_generation/test_image_generation.py
- Imported the new
imggen_with_txt
module. - Added a new test function
test_img_generation
to test the image generation functionality. - The test function calls the
generate_images
function fromimggen_with_txt.py
and asserts that the response is not empty.
- Imported the new
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A prompt given,
An image is born anew,
AI's art takes hold.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new image generation sample using the Gen AI SDK. The code is well-structured and easy to understand. The addition of a test case is also a good practice. However, there are a few areas that could be improved, such as adding a more descriptive prompt and removing the hardcoded GCS URI in the main function.
Summary of Findings
- Descriptive Prompt: The prompt "A dog reading a newspaper" is quite generic. Consider using a more descriptive prompt to showcase the capabilities of the image generation model.
- Hardcoded GCS URI: The
output_gcs_uri
in theif __name__ == "__main__"
block is hardcoded. It should be parameterized or removed to avoid accidental overwrites. - TODO comment: The TODO comment should be addressed or removed before merging.
Merge Readiness
The pull request is almost ready for merging. Addressing the TODO comment and the hardcoded GCS URI would significantly improve the code. While the prompt is not critical, a more descriptive prompt would enhance the sample's value. I am unable to approve the pull request, and other reviewers should review and approve this code before merging.
Description
Create a new Imagen image generation sample with the Gen AI SDK