π Try it in Colab: Google Colab Notebook
π GitHub File: image_generation.py
Generate professional product images using Google Vertex AI Imagen 3 to create studio-quality visuals from text prompts. πΌοΈβ¨
You can generate high-resolution AI-powered photos of [specify product, e.g., sneakers, jewelry, clothing], showcasing them from multiple angles while highlighting key details like [materials, textures, branding, lighting, etc.]. π¨π
git clone https://github.com/RobinaMirbahar/vertex-ai-imagen3-colab.git
cd vertex-ai-imagen3-colab
python -m venv venv
source venv/bin/activate # For Linux/Mac
venv\Scripts\activate # For Windows
pip install -r requirements.txt
β
1024x1024 Resolution - Studio-quality output
β
Multi-angle Generation - Show products from different views
β
Colab Integration - Cloud-based execution
β
Commercial Ready - Watermark-free options
π Run the notebook instantly in Google Colab:
π View the source code on GitHub:
image_generation.py
- Google Cloud account with billing enabled
- Vertex AI API enabled
- IAM permissions:
Vertex AI User
role
from google.colab import auth
auth.authenticate_user()
import vertexai
vertexai.init(project="YOUR-PROJECT-ID", location="us-central1")
from vertexai.preview import vision_models
from IPython.display import display
# Initialize model
generator = vision_models.ImageGenerationModel.from_pretrained("imagegeneration-002")
# Create 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)
# Customized generation with negative prompts
response = generator.generate_images(
prompt="Modern office chair with leather upholstery",
number_of_images=3,
negative_prompt="low quality, blurry, distorted, watermark",
aspect_ratio="16:9",
guidance_scale=20,
temperature=0.7,
person_generation="avoid"
)
Error | Solution |
---|---|
PermissionDenied: 403 |
Verify IAM roles & enable Vertex AI API |
InvalidModelName: 404 |
Check model name spelling & regional availability |
InvalidAspectRatio |
Use supported ratios: 1:1, 4:3, or 16:9 |
pip install --upgrade google-cloud-aiplatform
gcloud services enable aiplatform.googleapis.com
- π Imagen 3 Technical Docs
- π Python SDK Reference
- π Prompt Engineering Guide
- π Safety Filter Settings
We welcome contributions! Follow these steps to contribute:
- Fork the repository π
- Clone your fork
git clone https://github.com/your-username/vertex-ai-imagen3-colab.git cd vertex-ai-imagen3-colab
If you find this project helpful, feel free to β star the repository and π fork it to explore more!
Happy coding! π
Generated images must comply with Google's Generative AI Prohibited Use Policy. Ensure responsible and ethical use of AI-generated content. π