Skip to content

Latest commit

Β 

History

History
309 lines (221 loc) Β· 16.3 KB

README.md

File metadata and controls

309 lines (221 loc) Β· 16.3 KB

🎨 AI-Powered Studio-Quality Product Photos with Vertex AI Imagen 3

Open in Colab GitHub Stars Python Vertex AI License

πŸ”— Try it in Colab: Google Colab Notebook πŸ“‚ Source Code: image_generation.py


πŸ“– Overview

Generate professional, studio-quality product images using Google Vertex AI Imagen 3 β€” entirely from text prompts. Whether you're building an e-commerce store, a marketing campaign, or a product catalog, this tool lets you produce high-resolution AI-powered visuals at scale.

You can generate images of any product (sneakers, jewelry, clothing, electronics, and more), showcasing them from multiple angles while highlighting key details like materials, textures, branding, and lighting.


✨ Key Features

Feature Details
πŸ–ΌοΈ High Resolution 1024Γ—1024 studio-quality output
πŸ”„ Multi-angle Generation Show products from different views
☁️ Colab Integration Cloud-based, no local GPU needed
🚫 Watermark-Free Commercial-ready images
🎚️ Advanced Controls Guidance scale, temperature, negative prompts
πŸ›‘οΈ Safety Filters Configurable content safety settings

πŸš€ Quick Start

Run the notebook instantly in Google Colab β€” no setup required:

Open in Colab

Or clone and run locally (see Installation below).


πŸ”§ Installation & Setup

πŸ“‹ Prerequisites

Before you begin, make sure you have:

βš™οΈ Clone & Install

git clone https://github.com/RobinaMirbahar/vertex-ai-imagen3.git
cd vertex-ai-imagen3-colab

# Create and activate virtual environment
python -m venv venv
source venv/bin/activate        # Linux / macOS
venv\Scripts\activate           # Windows

# Install dependencies
pip install -r requirements.txt

πŸ” Authentication

In Google Colab:

from google.colab import auth
auth.authenticate_user()

import vertexai
vertexai.init(project="YOUR-PROJECT-ID", location="us-central1")

Locally (Service Account):

export GOOGLE_APPLICATION_CREDENTIALS="path/to/service-account-key.json"

πŸ“Έ Basic Usage

from vertexai.preview import vision_models
from IPython.display import display

# Initialize the model
generator = vision_models.ImageGenerationModel.from_pretrained("imagegeneration-002")

# Generate product images
response = generator.generate_images(
    prompt="Professional studio photo of luxury sneakers, 360 view, 4K resolution",
    number_of_images=4,
    aspect_ratio="1:1",
    guidance_scale=15,
    seed=1234
)

# Display results
for idx, image in enumerate(response.images):
    print(f"Image {idx + 1}")
    display(image._pil_image)

🎚️ Advanced Configuration

Use negative prompts, custom aspect ratios, and fine-tuned parameters for more control:

response = generator.generate_images(
    prompt="Modern office chair with leather upholstery, studio lighting",
    number_of_images=3,
    negative_prompt="low quality, blurry, distorted, watermark, shadow artifacts",
    aspect_ratio="16:9",        # Supported: "1:1", "4:3", "16:9"
    guidance_scale=20,          # Higher = more prompt-adherent (range: 1–30)
    temperature=0.7,            # Controls creativity (range: 0.0–1.0)
    person_generation="avoid"   # Options: "allow", "avoid"
)

βš™οΈ Parameter Reference

Parameter Type Description
prompt str Text description of the image to generate
number_of_images int Number of images to generate (1–8)
negative_prompt str Elements to exclude from the image
aspect_ratio str Output dimensions: "1:1", "4:3", "16:9"
guidance_scale float Prompt adherence strength (1–30)
temperature float Creativity level (0.0–1.0)
seed int Random seed for reproducibility
person_generation str Controls human appearance in output

πŸ“Š Example Outputs & Prompts

Category Prompt Preview
πŸ“· General Product "Professional studio photo of sneakers on a minimalistic background, soft diffused lighting, multiple angles" Sneakers
πŸ›’ E-Commerce Listing "Product images of a smartwatch β€” front, back, side views, plain white background, even lighting, realistic shadows" Smartwatch
πŸ’Ž Luxury / Premium "Studio-quality luxury wristwatch on black satin, dramatic lighting, fine textures and engravings highlighted" Luxury Watch
🏑 Lifestyle Shot "Aesthetic lifestyle shot of a designer handbag in a modern home, natural lighting, warm tones, cozy atmosphere" Handbag
πŸ”„ 360Β° View "Seamless 360-degree product series of a high-end DSLR camera, consistent lighting, high clarity for interactive shopping" DSLR Camera
βšͺ Minimalist "Clean product image of a wireless earbud case on a neutral gradient background, soft shadows, studio lighting" Earbuds
🌿 Outdoor / Adventure "Rugged outdoor product shot of a hiking backpack in a natural setting, earthy tones, dynamic lighting, scenic backdrop" Backpack

🧠 Prompt Engineering Tips

Writing better prompts leads to significantly better results. Here are some best practices:

  • Be specific about lighting: "soft diffused lighting", "dramatic side lighting", "golden hour sunlight"
  • Specify background: "plain white background", "black satin surface", "blurred outdoor setting"
  • Include view angles: "front view", "360-degree view", "top-down flat lay"
  • Add quality modifiers: "4K resolution", "ultra-realistic", "studio quality", "sharp focus"
  • Use negative prompts to exclude unwanted artifacts: "no watermark, no blurring, no distortion"

πŸ“– See the full Prompt Engineering Guide for more.


🚨 Troubleshooting

Common Errors & Fixes

Error Cause Solution
PermissionDenied: 403 Missing IAM permissions Verify Vertex AI User role is assigned
InvalidModelName: 404 Wrong model name or region Check spelling & regional availability
InvalidAspectRatio Unsupported ratio used Use "1:1", "4:3", or "16:9" only
QuotaExceeded API quota limit hit Request quota increase in Cloud Console
BillingNotEnabled GCP billing inactive Enable billing at console.cloud.google.com

Maintenance Commands

# Update the Vertex AI SDK
pip install --upgrade google-cloud-aiplatform

# Enable required GCP services
gcloud services enable aiplatform.googleapis.com

# Verify authentication
gcloud auth application-default print-access-token

πŸ“ Project Structure

vertex-ai-imagen3-colab/
β”œβ”€β”€ image_generation.py       # Core image generation script
β”œβ”€β”€ requirements.txt          # Python dependencies
β”œβ”€β”€ Images/                   # Sample output images
β”‚   β”œβ”€β”€ img0.png              # Sneakers example
β”‚   β”œβ”€β”€ img1.png              # Smartwatch example
β”‚   └── ...
└── README.md                 # This file

πŸ“š Documentation & Resources

Resource Link
πŸ“– Imagen 3 Technical Docs cloud.google.com/vertex-ai/docs
🐍 Python SDK Reference googleapis.dev/python/aiplatform
πŸ“ Prompt Engineering Guide Image Prompting Best Practices
πŸ”’ Safety Filter Settings Content Safety Docs
πŸ’° Pricing Vertex AI Pricing

🀝 Contributing

Contributions are welcome! Here's how to get started:

  1. Fork the repository πŸ”„
  2. Clone your fork:
    git clone https://github.com/your-username/vertex-ai-imagen3-colab.git
    cd vertex-ai-imagen3-colab
  3. Create a feature branch:
    git checkout -b feature/your-feature-name
  4. Commit your changes:
    git commit -m "Add: description of your change"
  5. Push and open a Pull Request πŸš€

Please follow existing code style and include comments where appropriate.


πŸ“„ License

This project is licensed under the Apache 2.0 License. See the LICENSE file for details.


⚠️ Disclaimer

All generated images must comply with Google's Generative AI Prohibited Use Policy. Please ensure responsible and ethical use of AI-generated content.


πŸ™Œ Acknowledgements

Built with ❀️ using Google Vertex AI Imagen 3.

If you find this project helpful:

  • ⭐ Star the repository
  • πŸ”„ Fork it to build your own version
  • πŸ“£ Share it with others who might benefit

Happy generating! πŸš€


πŸš€ Featured Google Cloud & Agentic AI Portfolio by Robina Mirbahar

Repository Architecture & Focus Live Status
gemma4-multilora-adk-eval Dynamic Multi-LoRA Hot-Swapping & CI/CD Agent Evaluation (adk eval) on Cloud Run GPUs with Gemma 4 & vLLM Stars Last Commit
slothsre-napops SlothSRE ("NapOps") β€” Overnight Gemma 4 & Google ADK Incident Digest Agent with OpenTelemetry & Sentry AI Monitoring Stars Last Commit
streamforge-event-adk Real-Time Event-Driven Multi-Agent Pipelines on Google Cloud with ADK (ParallelAgent & LoopAgent), Eventarc & Pub/Sub Stars Last Commit
a2a-mcp-mesh-cloudrun Agent-to-Agent (A2A) & Multi-MCP Mesh on Cloud Run with Gemma 4, Google ADK, Spanner Graph & AlloyDB Stars Last Commit
cloudguard-gemma-agent 6-Part Production Gemma Enterprise Agent Series (ADK, Cloud Run L4 GPU, Firestore, Model Armor, Vertex AI QLoRA) Stars Last Commit
Comic-Studio-Ai Multi-Agent Comic Generator powered by Google Gemini API & FastAPI deployed on Google Cloud Run Stars Last Commit
vertex-ai-imagen3 Generate AI-powered product & editorial images using Google Vertex AI Imagen 3 in Google Colab Stars Last Commit
Python-Learning-Assistant AI-powered Python tutor covering 50+ interactive exercises with real-time feedback built with Streamlit + Gemini API Stars Last Commit
cozy-ai-agent-cafe-game Prompt Paws: 60 FPS Cozy AI Agent Bakery Simulation Game teaching RAG, Guardrails, Context Caching & Multi-Agent Loops Stars Last Commit
Robina Mirbahar Banner

Star, Fork & Sponsor This Project

Star on GitHub Fork on GitHub Sponsor RobinaMirbahar

If this project is helpful to your work: