This repo is for developing a cloud-based visual AI workflow on Google Cloud Platform (GCP) by leveraging ComfyUI and Google Cloud's powerful foundation models.
This custom node pack for ComfyUI provides seamless integration with Google Cloud's Vertex AI services, allowing you to leverage powerful AI models directly within your ComfyUI workflows. This enables you to build sophisticated generative AI applications with the scalability and performance of Google Cloud.
This pack currently includes the following nodes:
| Node Name | Description |
|---|---|
| Gemini | Interacts with Google's Gemini Flash, Pro model for fast and efficient text generation, ideal for real-time chat, summarization, and rapid content creation. |
| Veo Video Generation | Generates video content using the Google Veo 2,3 model, an advanced text-to-video diffusion model capable of producing high-quality, diverse video clips from text and image prompts. |
| VideoPreviewNode | Used to preview video stored in Google Cloud Storage (GCS) directly within your ComfyUI workflow, providing immediate visual feedback for video generation processes. |
| Image to B64 Node | Converts an input image into a Base64 encoded string, useful for embedding image data in text-based formats (e.g., JSON, HTML) or for API transmissions. |
| Image Generation 3 | The primary node for generating high-quality images from text prompts using Google's Imagen 3 model, designed for diverse visual content creation. |
| Inpaint Insert w Mask | Inserts new content into a specified masked area of an image based on a text prompt, requiring an explicit mask to define the insertion region. |
| Inpaint Insert w AutoMask | Similar to "Inpaint Insert w Mask," but automatically generates the mask based on the prompt, streamlining the inpainting process. |
| Inpaint Insert w SemanticMask | Uses semantic understanding to intelligently generate a mask around specified objects (e.g., "the car") for precise content insertion based on a text prompt. |
| Inpaint Remove w Mask | Removes content from a specified masked area of an image and intelligently fills in the gap, requiring an explicit mask for removal. |
| Inpaint Remove w AutoMask | Similar to "Inpaint Remove w Mask," but automatically generates the mask for content removal based on the prompt. |
| Inpaint Remove w SemanticMask | Removes content based on semantic understanding, where the model automatically generates the mask around the specified object for removal (e.g., "remove the person"). |
| Imagen Product Background Swap w Mask | Replaces the background of a product image, requiring an explicit mask for the product to ensure clean separation from the original background. |
| Imagen Product Background Swap w AutoMask | Automatically detects the product and generates a mask for it, significantly speeding up the background swapping process for product images. |
| Imagen Mask-Free Editing | Enables image editing without the need for explicit masks. Users provide an image and a text prompt describing the desired change (e.g., "change the color"), and Imagen 3 intelligently applies the edits. |
| Imagen Outpainting | Extends the boundaries of an image beyond its original canvas, generating new content that seamlessly blends with the existing image based on a text prompt. |
Every Google Cloud resource belongs to a project. If you don't have one, create a new project:
- Go to the Google Cloud Console.
- In the top navigation bar, click the project dropdown (usually displaying "My First Project" or your current project name).
- Click "New Project".
- Enter a Project name (e.g.,
my-api-access-project). - (Optional) Choose an Organization and Location if applicable.
- Click "Create".
- Once the project is created, ensure it is selected in the project dropdown in the Cloud Console. Note down your Project ID (e.g.,
my-api-access-project-123456) as you'll need it later.
For your application to use a specific Google Cloud service (e.g., Cloud Storage, Vertex AI, Gemini for Google Cloud API), you must enable its corresponding API in your project.
- In the Google Cloud Console, navigate to the Navigation menu (☰) on the top left.
- Go to APIs & Services > Dashboard.
- Click "+ ENABLE APIS AND SERVICES" at the top.
- In the API Library, search for the API you need (e.g., "Vertex AI API", "Gemini for Google Cloud API", "Cloud Storage API").
- Click on the API you want to enable.
- Click the "Enable" button.
Google Cloud APIs require authentication to verify your application's identity and permissions. There are two primary methods for local development:
This method uses your personal Google account credentials to authenticate your gcloud CLI, which then automatically provides Application Default Credentials (ADC) to your local applications. This is the simplest and most secure method for individual development.
-
Ensure
gcloudCLI is installed: If not, follow the installation guide. -
Log in to your Google Account via
gcloud: Open your terminal or command prompt and run:gcloud auth login
This command will open a browser window, prompting you to log in with your Google account. After successful login, you can close the browser.
-
Set your Google Cloud Project: Tell
gcloudwhich project to use for subsequent commands and for ADC:gcloud config set project YOUR_PROJECT_IDReplace
YOUR_PROJECT_IDwith the actual ID of the project you created (e.g.,my-api-access-project-123456). -
Verify Authentication: You can verify your active account and project:
gcloud auth list gcloud config list project
Now, any Google Cloud client library or application running in your local environment that uses Application Default Credentials will automatically use the authenticated gcloud credentials.
For production environments, CI/CD pipelines, or situations where you don't want to use a personal account, service accounts are the secure and recommended method. A service account is a special type of Google account that represents your application rather than an individual user.
Caution: Service account key files grant powerful access. Keep them secure and never commit them to version control.
Create a Service Account:
- Go to the Google Cloud Console.
- Navigate to the Navigation menu (☰) > IAM & Admin > Service Accounts.
- Click "+ CREATE SERVICE ACCOUNT".
- Enter a Service account name (e.g.,
my-local-api-sa) and an optional description. - Click "CREATE AND CONTINUE".
Grant Permissions (Roles):
- In the "Grant this service account access to project" section, select the roles necessary for your application to interact with the required APIs. Grant the principle of least privilege: only give the permissions absolutely needed.
- For example, if you're using Cloud Storage, you might grant
Storage Object AdminorStorage Object Viewer. If using Vertex AI, you might grantVertex AI UserorVertex AI Administrator.
- For example, if you're using Cloud Storage, you might grant
- Click "CONTINUE".
Create a Key (JSON File):
- In the "Grant users access to this service account" section (optional, skip if not needed), click "DONE".
- On the Service Accounts page, find your newly created service account.
- Click on the three dots (⋮) under the "Actions" column for your service account.
- Select "Manage keys".
- Click "ADD KEY" > "Create new key".
- Choose "JSON" as the key type.
- Click "Create".
- Your browser will download a JSON key file (e.g.,
your-service-account-name-xxxx.json). Save this file in a secure location on your local machine.
Set the GOOGLE_APPLICATION_CREDENTIALS Environment Variable:
Most Google Cloud client libraries automatically detect credentials if the GOOGLE_APPLICATION_CREDENTIALS environment variable is set to the path of your service account JSON key file.
-
Linux/macOS:
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your-service-account-key.json"
Important: This environment variable is usually session-specific. For persistent access, you might add this line to your shell's profile file (e.g., .bashrc, .zshrc, ~/.profile for Linux/macOS, or configure it in your IDE/system environment variables). However, for development, setting it per-session or through your IDE's run configurations is often safer.
-
Navigate to your ComfyUI
custom_nodesdirectory. -
Add the contents of this repository to the
custom_nodesdirectory. -
Set configurations in
config.yamlfile. You can find these values in your Google Cloud Console. -
Install the dependencies present in the
requirements.txtfile. You can do this by running the following command in your terminal:pip install -r requirements.txt
-
Restart the ComfyUI server.
- Navigate to your ComfyUI
custom_nodesdirectory. - Clone the git repo under
custom_nodesdirectory. - Restart the ComfyUI server.
After installing and restarting ComfyUI, you will find the "VertexAI" category added to the node menu.