diff --git a/reference_images/kai_master_stylea.png b/reference_images/kai_master_stylea.png new file mode 100644 index 000000000..5710ac793 Binary files /dev/null and b/reference_images/kai_master_stylea.png differ diff --git a/reference_images/kai_master_styleb.png b/reference_images/kai_master_styleb.png new file mode 100644 index 000000000..65d0a58ee Binary files /dev/null and b/reference_images/kai_master_styleb.png differ diff --git a/scripts/test_character_consistency.py b/scripts/test_character_consistency.py new file mode 100644 index 000000000..08c9ddc2b --- /dev/null +++ b/scripts/test_character_consistency.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +""" +Test Character Consistency - Generate Kai walking animation frames +""" + +import vertexai +from vertexai.preview.vision_models import ImageGenerationModel, Image +from pathlib import Path + +# Initialize +vertexai.init(project="gen-lang-client-0428644398", location="us-central1") + +# Load Kai reference (Style A - Cartoon) +kai_reference_path = Path("reference_images/kai_master_stylea.png") +kai_reference = Image.load_from_file(str(kai_reference_path)) + +print("="*60) +print("๐ŸŽฎ KAI CHARACTER CONSISTENCY TEST") +print("="*60) +print(f"๐Ÿ“ธ Reference: {kai_reference_path}") +print() + +# Animation frames to generate +frames = [ + { + "name": "kai_walk_frame1", + "prompt": "Same character Kai exactly as shown, walking animation, left leg forward step, right arm forward. Maintain exact same face, green hair, backpack, blue jeans, and brown boots. Cartoon vector style with bold outlines. Solid bright green background (#00FF00)." + }, + { + "name": "kai_walk_frame2", + "prompt": "Same character Kai exactly as shown, walking animation, standing upright neutral pose, both feet together. Maintain exact same face, green hair, backpack, blue jeans, and brown boots. Cartoon vector style with bold outlines. Solid bright green background (#00FF00)." + }, + { + "name": "kai_walk_frame3", + "prompt": "Same character Kai exactly as shown, walking animation, right leg forward step, left arm forward. Maintain exact same face, green hair, backpack, blue jeans, and brown boots. Cartoon vector style with bold outlines. Solid bright green background (#00FF00)." + } +] + +model = ImageGenerationModel.from_pretrained("imagegeneration@006") + +# Generate frames +for i, frame in enumerate(frames, 1): + print(f"\n๐ŸŽจ Generating Frame {i}/3: {frame['name']}") + print(f"๐Ÿ“ Prompt: {frame['prompt'][:80]}...") + + try: + # Use edit_image with reference for consistency + response = model.edit_image( + base_image=kai_reference, + prompt=frame['prompt'], + edit_mode="inpainting-insert", + negative_prompt="different character, different face, different hair color, different clothing, different proportions, watermark, text" + ) + + output_path = Path(f"test_character/{frame['name']}.png") + output_path.parent.mkdir(exist_ok=True) + + response.images[0].save(location=str(output_path)) + + print(f"โœ… Saved: {output_path}") + + except Exception as e: + print(f"โŒ Error: {e}") + +print("\n" + "="*60) +print("โœ… TEST COMPLETE!") +print("๐Ÿ“ Check: test_character/ folder") +print("="*60) diff --git a/scripts/test_character_seed.py b/scripts/test_character_seed.py new file mode 100644 index 000000000..fde7b14fc --- /dev/null +++ b/scripts/test_character_seed.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +""" +Test Character Consistency - SEED method +Generate Kai walking frames with CONSISTENT SEED +""" + +import vertexai +from vertexai.preview.vision_models import ImageGenerationModel +from pathlib import Path + +# Initialize +vertexai.init(project="gen-lang-client-0428644398", location="us-central1") + +print("="*60) +print("๐ŸŽฎ KAI CHARACTER CONSISTENCY TEST - SEED METHOD") +print("="*60) + +# Base character description +base_character = """ +Young male farmer character named Kai. Green spiky hair, determined expression, wearing dark blue jean jacket over white shirt, backpack, ripped blue jeans, and brown boots. Cartoon vector art style with bold black outlines (1.4px), flat vibrant colors, clean playful aesthetic. +""" + +# Animation frames with SAME SEED +frames = [ + { + "name": "kai_seed_idle", + "prompt": f"{base_character} Standing idle pose, front facing view. Solid bright green background (#00FF00), centered character." + }, + { + "name": "kai_seed_walk1", + "prompt": f"{base_character} Walking animation, left leg forward step, right arm swinging forward. Solid bright green background (#00FF00), centered character." + }, + { + "name": "kai_seed_walk2", + "prompt": f"{base_character} Walking animation, neutral standing pose between steps. Solid bright green background (#00FF00), centered character." + }, + { + "name": "kai_seed_walk3", + "prompt": f"{base_character} Walking animation, right leg forward step, left arm swinging forward. Solid bright green background (#00FF00), centered character." + } +] + +model = ImageGenerationModel.from_pretrained("imagegeneration@006") + +SEED = 12345 # โ† ISTO ลกtevilo za vse frame = boljลกa konsistentnost! + +# Generate frames +for i, frame in enumerate(frames, 1): + print(f"\n๐ŸŽจ Generating Frame {i}/4: {frame['name']}") + print(f"๐Ÿ“ Using SEED: {SEED}") + + try: + response = model.generate_images( + prompt=frame['prompt'], + number_of_images=1, + seed=SEED, # โ† ISTI SEED! + aspect_ratio="1:1", + guidance_scale=15, # Higher = stricter prompt following + safety_filter_level="block_some", + person_generation="allow_adult" + ) + + output_path = Path(f"test_character/{frame['name']}.png") + output_path.parent.mkdir(exist_ok=True) + + response.images[0].save(location=str(output_path)) + + print(f"โœ… Saved: {output_path}") + + except Exception as e: + print(f"โŒ Error: {e}") + +print("\n" + "="*60) +print("โœ… TEST COMPLETE!") +print("๐Ÿ“ Check: test_character/ folder") +print("๐Ÿ” Compare frames for consistency!") +print("="*60)