# APNG Lip Sync Tool 개발기 - v6: Gemini Image로 입모양 생성 ## 개요 Gemini 2.5 Flash Image (Nano Banana)를 활용하여 원본 이미지에서 다양한 입모양 변형을 생성합니다. ## 핵심 함수 ```python def generate_viseme_image(original_image_path, viseme, viseme_description, output_path): """Generate a viseme variation of the original image.""" prompt = f"""Edit this face image to change ONLY the mouth shape. Target mouth shape: {viseme} - {viseme_description} Instructions: 1. Keep the face, eyes, hair, and all other features exactly the same 2. Only modify the mouth/lips area 3. The mouth should show: {viseme_description} 4. Maintain the same art style and quality 5. The transition should look natural""" response = client.models.generate_content( model=GEMINI_IMAGE_MODEL, contents=[prompt, image_part], config=types.GenerateContentConfig( response_modalities=["IMAGE", "TEXT"] ) ) # Extract generated image for part in response.candidates[0].content.parts: if part.inline_data.mime_type.startswith("image/"): with open(output_path, "wb") as f: f.write(part.inline_data.data) ``` ## 일괄 생성 ```python def generate_all_visemes(image_path, character_name): """Generate all viseme images for a character.""" for viseme, description in VISEME_SET.items(): generate_viseme_image( original_image_path=image_path, viseme=viseme, viseme_description=description, output_path=char_dir / f"{viseme}.png" ) ``` ## 결과 원본 이미지 하나로 11개의 입모양 변형 이미지가 생성됩니다. --- *다음: v7 - APNG 생성 로직*