Files
novafarma/scripts/test_vertex_ai_simple.py
David Kotnik 5e23cbece0 🚀 Complete biome infrastructure + Vertex AI setup prep
TODAY'S ACCOMPLISHMENTS (01.01.2026):

DINO VALLEY GENERATION:
 Terrain: 16/16 PNG (100% complete)
 Vegetation: 20/20 PNG (100% complete)
🟨 Props: 2/40 PNG (5% started)
📊 Total: 69/212 PNG (33% Dino Valley complete)

NEW DOCUMENTATION:
 ALL_BIOMES_COMPLETE_BREAKDOWN.md - Complete 21-biome manifest (3,121 PNG total)
 GEMINI_WEB_UI_BIOME_PROMPTS.md - Ready-to-use generation prompts
 VERTEX_AI_SETUP_GUIDE.md - Step-by-step Vertex AI Imagen setup
 SESSION_DNEVNIK_01_01_2026.md - Complete session diary

NEW AUTOMATION SCRIPTS:
 scripts/generate_all_biomes_complete.py - Intelligent batch generator
 scripts/test_vertex_ai_simple.py - Vertex AI test script
 scripts/test_imagen.py - Imagen API test
 scripts/test_minimal.py - Minimal API test

INFRASTRUCTURE:
 All 21 biome directories with 10 categories each (210 folders)
 Dual art style system (Style A + Style B) fully operational
 Green chroma key background standard (#00FF00)

COMMITS TODAY: 5 (45 files modified/created)
IMAGES GENERATED: 38 PNG (33 new + 5 earlier)
TIME SPENT: ~7 hours
RATE LIMITING: Major bottleneck identified - Vertex AI is solution

NEXT STEPS:
1. Complete Vertex AI setup (gcloud auth)
2. Test image generation via Vertex API
3. Run bulk generation for remaining 3,052 PNG
4. Background removal batch processing
5. Complete all 21 biomes

STATUS: Production infrastructure ready, awaiting Vertex AI activation!
2026-01-01 19:56:09 +01:00

77 lines
2.2 KiB
Python

#!/usr/bin/env python3
"""
VERTEX AI IMAGEN - SIMPLE SETUP
Using Application Default Credentials (easiest method)
"""
import vertexai
from vertexai.preview.vision_models import ImageGenerationModel
import os
from pathlib import Path
# ========================================
# CONFIGURATION
# ========================================
PROJECT_ID = "gen-lang-client-0428644398" # Your Google Cloud project
LOCATION = "us-central1" # Imagen location
# Initialize Vertex AI
vertexai.init(project=PROJECT_ID, location=LOCATION)
# ========================================
# IMAGE GENERATION
# ========================================
def generate_image_vertex(prompt, output_path):
"""Generate image using Vertex AI Imagen"""
print(f"🎨 Generating: {output_path.name}")
print(f"📝 Prompt: {prompt[:80]}...")
try:
# Load the model
model = ImageGenerationModel.from_pretrained("imagegeneration@006")
# Generate image
response = model.generate_images(
prompt=prompt,
number_of_images=1,
aspect_ratio="1:1",
safety_filter_level="block_some",
person_generation="allow_adult"
)
# Save image
output_path.parent.mkdir(parents=True, exist_ok=True)
response.images[0].save(location=str(output_path))
print(f"✅ Saved: {output_path}")
return True
except Exception as e:
print(f"❌ Error: {e}")
return False
# ========================================
# EXAMPLE USAGE
# ========================================
if __name__ == "__main__":
# Test generation
test_prompt = "2D game prop, cartoon vector art with bold black outlines, flat vibrant colors. Asset: DINOSAUR SKULL with teeth. Background: SOLID BRIGHT GREEN (#00FF00)"
test_output = Path("test_vertex_output.png")
print("="*60)
print("🦖 VERTEX AI IMAGEN - TEST")
print("="*60)
success = generate_image_vertex(test_prompt, test_output)
if success:
print("\n✅ SUCCESS! Vertex AI is working!")
print(f"📁 Check: {test_output}")
else:
print("\n❌ FAILED! Check credentials.")