-
Notifications
You must be signed in to change notification settings - Fork 6.5k
feat(genai): Add new image generation samples #13320
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
feat(genai): Add new image generation samples #13320
Conversation
Here is the summary of changes. You are about to add 5 region tags.
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 introduces new code samples for Imagen Customization using the Google Gen AI SDK for Python. It includes examples for canny edge detection, scribble customization, style customization, style transfer, and subject customization. Each sample demonstrates how to use the edit_image
method with different configurations to achieve various image editing effects.
Highlights
- New Samples: Adds five new code samples demonstrating different Imagen customization techniques: canny edge, scribble, style, style transfer, and subject customization.
- Image Editing: Each sample uses the
edit_image
method of the Google Gen AI SDK to modify images based on prompts and reference images. - Configuration: The samples utilize various configuration options such as
EditImageConfig
,ControlReferenceConfig
,StyleReferenceConfig
, andSubjectReferenceConfig
to control the image editing process.
Changelog
Click here to see the changelog
- genai/image_generation/img_customization_canny_edge.py
- Introduces a new sample demonstrating image customization using canny edge detection.
- Uses
ControlReferenceImage
andControlReferenceConfig
to specify the canny edge control type. - The sample takes an image of a car with canny edges and generates a watercolor painting of a red car driving on a road, using the canny edges as a guide.
- genai/image_generation/img_customization_scribble.py
- Introduces a new sample demonstrating image customization using scribble.
- Uses
ControlReferenceImage
andControlReferenceConfig
to specify the scribble control type. - The sample takes an image of a car with scribbles and generates an oil painting showing the side of a red car, using the scribbles as a guide.
- genai/image_generation/img_customization_style.py
- Introduces a new sample demonstrating image customization using style reference.
- Uses
StyleReferenceImage
andStyleReferenceConfig
to specify the style description. - The sample takes an image of a neon sign and generates an image of a neon sign with the words 'have a great day', using the style of the reference image.
- genai/image_generation/img_customization_style_transfer.py
- Introduces a new sample demonstrating image customization using style transfer.
- Uses
RawReferenceImage
to specify the style image. - The sample takes an image of a teacup and transforms it so that the teacup is made entirely out of chocolate, using the style of the reference image.
- genai/image_generation/img_customization_subject.py
- Introduces a new sample demonstrating image customization using subject reference and face mesh control.
- Uses
SubjectReferenceImage
,SubjectReferenceConfig
,ControlReferenceImage
, andControlReferenceConfig
to specify the subject and control type. - The sample takes a headshot of a woman and generates a portrait of a woman in the pose of the control image in a watercolor style.
- genai/image_generation/noxfile_config.py
- Adds a default TEST_CONFIG_OVERRIDE for python repos.
- Specifies ignored Python versions and enforces type hints.
- genai/image_generation/requirements-test.txt
- Adds pytest as a test dependency.
- genai/image_generation/requirements.txt
- Adds google-genai as a dependency.
- genai/image_generation/test_img_customization.py
- Introduces new tests for the image customization samples.
- Sets environment variables for using Vertex AI.
- Each test asserts that the length of the generated image bytes is greater than 1000.
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.
With Imagen's artful hand,
Images transform at command.
From scribble's trace,
A new image we embrace,
AI's magic, across the land.
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 new code samples for Imagen Customization using the Google Gen AI SDK for Python. The samples cover various customization techniques like Canny edge, scribble, style, style transfer, and subject customization. Overall, the code is well-structured and easy to understand. However, there are a few areas that could be improved for better clarity and maintainability.
Summary of Findings
- Missing Error Handling: The code samples lack explicit error handling. It's crucial to handle potential exceptions, such as network errors or API failures, to ensure the robustness of the samples.
- Inconsistent Variable Naming: There are some inconsistencies in variable naming across the different code samples. Maintaining a consistent naming convention improves readability and reduces cognitive load.
- Hardcoded Values: The code uses hardcoded values for parameters like model name and GCS URIs. Consider making these configurable or using constants to improve flexibility and maintainability.
Merge Readiness
The pull request introduces valuable code samples for Imagen Customization. However, addressing the identified issues, particularly the missing error handling, is crucial before merging. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. At a minimum, the high severity issues should be addressed before merging.
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.
LGTM, deferring to @msampathkumar on Sample Region Tags/File names
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.
Nice work @katiemn 👍
Description
Add new code samples for Imagen Customization using the Google Gen AI SDK for Python