Imagen by Vertex AI Tutorial

Wednesday, July 26, 2023 by abdibrokhim
Imagen by Vertex AI Tutorial

Introduction

Imagen by Vertex AI is the powerful text-to-image generation tool that allows us not only to generate images, however edit and analyze them.

Generating Images - We can generate images by providing a prompt. For example, we can generate an image of a cat wearing a hat.

Editing Images - Here we can edit the generated images or upload a new image and edit it. It allows us to go beyond the generated image and turn on our imagination. Like changing the background, adding text description, changing the color of the hat or material, changing the color of the cat or fur, and more.

Analyzing Images - We can generate captions for the image, ask questions about the image. For example, we can ask what is in the image, what is the color of the hat, what is the material of the hat, mood of the cat, and more.

Prerequisites

To use Imagen by Vertex AI you should REQUEST ACCESS. Simply fill out the form and you should be good to go.

request access form
request access form

If you don't have a Google Cloud account yet, you can create one for free. Please, follow up Chirp Tutorial it provides step-by-step guide to create a Google Cloud account set up a new project, bucket end etc.

Time to Dive In!

I will provide screenshots to make it more convinient and easy to digest. Let's get started!

If you already created an account and set up a project. Go to Google Cloud Console.

google cloud console
google cloud console

Now, click burger menu on the top left corner and select APIs & Services > Library.

api & services
api & services

Then, search for Vertex AI API, select the first Vision AI API and click Enable button. After that, you will be redirected to the main page. You may leave all the settings as default for now.

vision
vision
enable
enable
api settings
api settings

Next, open up the burger menu again and select Vertex AI > Vision.

vertex api vision
vertex api vision

You should see the following page. This is the main page of Vertex AI Vision. Here we will generate images, edit them, generate captions and ask questions about the image.

vision dashboard
vision dashboard

Generating Images

Let's start with generating images. Click GENERATE button. And below in the textarea enter the following prompt:

A photo of a cat wearing a hat

Now, click GENERATE button:

generate
generate

Full image:

generate
generate

You can generate more images by clicking GENERATE button again. You can also edit the image by clicking EDIT button. You can change the image, add text, change the background, and more.

Editing Images

Let's try to edit the image. Click EDIT button and turn on your imagination. For now, I will simply extract the background. Feel free to play around EDIT feature.

image
image
image
image

Analyzing Images

You can also generate captions for the image. Click CAPTION button and upload the image you want to generate caption for, then click GENERATE CAPTION.

image
image
caption
caption

Next, let's ask questions about the image. Click VISUAL Q&A button and ask any question you want. I tried the following questions:

What is the color of the hat?
caption
caption
What is the color of the background?
caption
caption
What is in the image?
caption
caption
What is the cat wearing?
caption
caption

Feel free to change the number of answers, captions, generated images you want to get by sliding the slider on the right side.

slider
slider

Conclusion

Throughout the tutorial, I utilized screenshots to provide visual guidance and make the learning process more accessible. By following these steps, I hope you gained a comprehensive understanding of Imagen by Vertex AI and its capabilities.

Thank you for following along with this tutorial.