Skip to content
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: Brochure Creation Notebook #460

Merged
merged 21 commits into from May 16, 2024
Merged

Conversation

slatawa
Copy link
Contributor

@slatawa slatawa commented Mar 27, 2024

Description

Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Follow the CONTRIBUTING Guide.
  • You are listed as the author in your notebook or README file.
    • Your account is listed in CODEOWNERS for the file(s).
  • Make your Pull Request title in the https://www.conventionalcommits.org/ specification.
  • Ensure the tests and linter pass (Run nox -s format from the repository root to format).
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@slatawa slatawa requested a review from a team as a code owner March 27, 2024 06:02
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:16Z
----------------------------------------------------------------

Can you link the other author's github page?


slatawa commented on 2024-05-10T04:47:57Z
----------------------------------------------------------------

Added

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:16Z
----------------------------------------------------------------

Remove the extra title in this cell.

Change the objectives to be all the same tense. e.g.

  • Create background images for product brochures
  • Place product image on top of the background along with text like company name
  • Add company logo image, if provided


slatawa commented on 2024-05-10T04:50:58Z
----------------------------------------------------------------

Incorporated

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:17Z
----------------------------------------------------------------

Change these pip installs to one line, include upgrade, quiet and install vertex ai sdk

%pip install --upgrade --user -q google-cloud-aiplatform rembg Pillow opencv-python numpy requests gradio


slatawa commented on 2024-05-10T04:52:09Z
----------------------------------------------------------------

Changed

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:18Z
----------------------------------------------------------------

Remove else not needed


slatawa commented on 2024-05-10T04:55:00Z
----------------------------------------------------------------

Updated

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:19Z
----------------------------------------------------------------

Add vertex ai imports and initialize vertex sdk at the beginning


slatawa commented on 2024-05-10T08:33:17Z
----------------------------------------------------------------

Done

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:19Z
----------------------------------------------------------------

Replace project id with a placeholder


slatawa commented on 2024-05-10T05:59:39Z
----------------------------------------------------------------

Updated

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:20Z
----------------------------------------------------------------

I'm not sure this is needed.


slatawa commented on 2024-05-10T05:59:57Z
----------------------------------------------------------------

have removed these now

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:21Z
----------------------------------------------------------------

Describe what these prompts are for.


slatawa commented on 2024-05-10T06:02:31Z
----------------------------------------------------------------

Added description

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:22Z
----------------------------------------------------------------

Clarify more what the code is doing. It's using Gemini to generate an Imagen prompt.


slatawa commented on 2024-05-10T07:11:58Z
----------------------------------------------------------------

Added details on this

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:22Z
----------------------------------------------------------------

Line #3.    import vertexai.preview.generative_models as generative_models

You shouldn't need this extra import. Just import the specific classes/modules from generative_models


slatawa commented on 2024-05-10T07:12:53Z
----------------------------------------------------------------

this has been removed now

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:23Z
----------------------------------------------------------------

Line #5.    def generate_imagen_prompt_using_llm(temperature, colors , is_blurred, patterns,style ):

Add type hints to this function.

Also change is_blurred to be a boolean.


slatawa commented on 2024-05-10T07:18:32Z
----------------------------------------------------------------

Updated

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:24Z
----------------------------------------------------------------

Line #6.        vertexai.init(project=PROJECT_ID, location=REGION)

Put this once at the beginning of the notebook.


slatawa commented on 2024-05-10T07:19:06Z
----------------------------------------------------------------

updated

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:25Z
----------------------------------------------------------------

Line #9.        add_blur_text = ""

This can be simplified to:

add_blur_text = "Blur the generated Image" if is_blurred else ""

slatawa commented on 2024-05-10T07:20:01Z
----------------------------------------------------------------

Updated

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:25Z
----------------------------------------------------------------

Line #32.           generation_config={

Use the GenerationConfig class


slatawa commented on 2024-05-10T09:03:27Z
----------------------------------------------------------------

Resolved

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:26Z
----------------------------------------------------------------

Line #51.        return prompt_str

This can be simplified.

I'd recommend not using stream for this use case. Then you can just return response.text


slatawa commented on 2024-05-10T08:58:24Z
----------------------------------------------------------------

Done

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:27Z
----------------------------------------------------------------

Line #1.    from vertexai.preview.vision_models import ImageGenerationModel

Move these imports to the top of the notebook.


slatawa commented on 2024-05-10T07:24:20Z
----------------------------------------------------------------

Removed

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:28Z
----------------------------------------------------------------

Line #8.        seed = None,

Add types for all parameters


slatawa commented on 2024-05-10T07:27:11Z
----------------------------------------------------------------

Updated

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:28Z
----------------------------------------------------------------

Line #11.        ):

Add return type.


slatawa commented on 2024-05-10T07:28:32Z
----------------------------------------------------------------

Added

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:29Z
----------------------------------------------------------------

Line #22.            image_bytes = io.BytesIO(image._image_bytes)  # Convert to in-memory file 

I don't think you need to do all of this?

You can directly access the PIL Image through

image._pil_image

https://github.com/googleapis/python-aiplatform/blob/b587a8d0f10272baf30593dfbc3f178410ba6341/vertexai/vision_models/_vision_models.py#L118C9-L118C19

And display the image through

image.show()


slatawa commented on 2024-05-10T09:07:43Z
----------------------------------------------------------------

Resolved

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:30Z
----------------------------------------------------------------

Line #2.    def make_brochure(subject_image,bg_image,logo_image,banner_color):

Add parameter and return types


slatawa commented on 2024-05-10T07:31:23Z
----------------------------------------------------------------

UPdated

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:31Z
----------------------------------------------------------------

Line #4.        # subject_image = Image.open(subject_image_path) # load image

Remove commented out code


slatawa commented on 2024-05-10T07:32:33Z
----------------------------------------------------------------

removed

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:31Z
----------------------------------------------------------------

Line #47.        if position == "top right":

This position should probably be an enum.


slatawa commented on 2024-05-10T07:36:49Z
----------------------------------------------------------------

UPDATED

Copy link

review-notebook-app bot commented Mar 27, 2024

View / edit / reply to this conversation on ReviewNB

holtskinner commented on 2024-03-27T15:26:32Z
----------------------------------------------------------------

Line #1.    import time

move all imports to top of notebook


slatawa commented on 2024-05-10T07:37:26Z
----------------------------------------------------------------

updated

@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label May 10, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 10, 2024
@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label May 10, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 10, 2024
@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label May 13, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 13, 2024
@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label May 15, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 15, 2024
@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label May 15, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 15, 2024
@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label May 15, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 15, 2024
@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label May 15, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 15, 2024
@GoogleCloudPlatform GoogleCloudPlatform deleted a comment from github-actions bot May 15, 2024
@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label May 16, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 16, 2024
@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label May 16, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 16, 2024
@holtskinner holtskinner enabled auto-merge (squash) May 16, 2024 20:03
@holtskinner holtskinner merged commit b9a49c7 into GoogleCloudPlatform:main May 16, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants