반복적인 이미지 프롬프트 개선
생성된 이미지를 분석하고 프롬프트를 체계적으로 조정합니다.
반복적인 이미지 프롬프트 개선은(는) CoddyKit의 무료 AI Prompt Engineering 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 AI Prompt Engineering 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. AI Prompt Engineering 강의에는 총 4개의 강의가 포함되어 있습니다.
반복적 개선이 필요한 이유
첫 번째 이미지 프롬프트 generation에서 원하는 결과가 정확히 나오는 경우는 드뭅니다. 반복적 개선은 체계적인 작업 흐름입니다. generate하고, 분석하고, 부족한 점을 찾고, 프롬프트를 조정한 뒤 다시 generate합니다. 각 주기를 거치면서 의도와 출력 사이의 차이를 좁혀 갑니다.
개선 순환 과정
반복적 개선 순환 과정은 네 단계로 이루어집니다. Generate(현재 프롬프트로 이미지를 create), 분석(잘못되었거나 빠진 부분을 찾기), 조정(문제를 해결하도록 프롬프트 수정), 그리고 다시 생성입니다. 만족할 때까지 또는 예산과 시간 제약으로 중단될 때까지 반복합니다.
class PromptRefinementSession:
def __init__(self, initial_prompt, negative_prompt=''):
self.history = []
self.current_prompt = initial_prompt
self.current_negative = negative_prompt
self.iteration = 0
def record_iteration(self, issues_found, adjustments_made):
self.history.append({
'iteration': self.iteration,
'prompt': self.current_prompt,
'negative': self.current_negative,
'issues': issues_found,
'adjustments': adjustments_made
})
self.iteration += 1
def update_prompt(self, new_prompt, new_negative=None):
self.current_prompt = new_prompt
if new_negative is not None:
self.current_negative = new_negative
def get_history(self):
return self.history
# Usage
session = PromptRefinementSession(
initial_prompt='a woman walking in a rainy city at night',
negative_prompt='blurry, low quality'
)
print('Refinement session started. Iteration 0.')generate된 이미지 분석: 문제 분류 체계
무엇이 잘못되었는지 분석할 때는 문제를 유형별로 분류하세요. 그러면 프롬프트의 어느 부분을 조정해야 하는지, 즉 세부 사항을 추가할지, 충돌을 제거할지, 가중치를 조정할지 결정할 수 있습니다.
ISSUE_TAXONOMY = {
'Subject issues': [
'Subject missing or wrong species/gender/age',
'Key detail absent (clothing, expression, props)',
'Pose or action incorrect',
'Background wrong or distracting'
],
'Style issues': [
'Wrong art style (photo when painting expected)',
'Too stylized/not stylized enough',
'Style inconsistency (mixing styles incoherently)'
],
'Lighting issues': [
'Wrong time of day',
'Too dark or too bright',
'Shadows wrong direction',
'Missing dramatic effect'
],
'Composition issues': [
'Wrong framing (too close/far)',
'Subject cropped awkwardly',
'Rule of thirds not applied',
'Cluttered vs. desired clean composition'
],
'Quality issues': [
'Blurry or low detail',
'Anatomical distortion (extra fingers)',
'Watermark or text artifact',
'Overexposed/underexposed areas'
]
}
for category, issues in ISSUE_TAXONOMY.items():
print(f'{category}: {issues[0]}')반복 1: 전과 후
문제를 파악하고 프롬프트를 조정하면 결과가 어떻게 개선되는지 보여 주는 구체적인 전후 예시입니다.
# ITERATION 0: Initial prompt (too vague)
prompt_v0 = 'a woman walking in a rainy city at night'
# Issues found:
# - Style unspecified -> model defaulted to generic illustration
# - Lighting unspecified -> flat even light, no mood
# - No detail on clothing or setting
# - No composition direction
# ITERATION 1: Add style, lighting, detail
prompt_v1 = (
'a young woman in a yellow raincoat walking down '
'a rain-soaked Tokyo street at night, '
'neon signs reflected in puddles, steam rising from grates, '
'cinematic photography style, street photography, '
'warm neon glow, wet pavement reflections, '
'medium shot, slightly low angle, bokeh background'
)
negative_v1 = 'blurry, low quality, watermark, extra fingers, cartoon'
# Remaining issues after v1:
# - Raincoat not yellow (model defaulted to dark colors)
# - Woman facing wrong way
print('V0 length:', len(prompt_v0.split()))
print('V1 length:', len(prompt_v1.split()))
print('Iteration adds: style, lighting, composition, specific details')반복 2: 특정 요소 수정
두 번째 반복에서는 남은 문제를 정확하게 해결합니다. 프롬프트 전체를 다시 작성하지 말고, 반복 1에서 발견한 구체적인 문제만 다루세요.
# ITERATION 1 issues:
# - Raincoat not yellow (model defaulted to dark)
# - Woman facing wrong way (walking away from camera)
# ITERATION 2: targeted fixes
prompt_v2 = (
'a young woman in a BRIGHT YELLOW raincoat '
'walking TOWARD the camera '
'down a rain-soaked Tokyo street at night, '
'neon signs reflected in puddles, steam rising from grates, '
'face visible, slight smile, carrying groceries, '
'cinematic photography style, street photography, '
'warm neon glow, wet pavement reflections, '
'medium shot, slightly low angle, bokeh background'
)
# Changes made:
# 1. "BRIGHT YELLOW" capitalization + adjective for emphasis
# 2. Added "walking TOWARD the camera" to fix direction
# 3. Added "face visible" to prevent back-to-camera result
# 4. Added specific detail: "carrying groceries, slight smile"
# Best practice: track what you changed and why
changelog = {
'v0_to_v1': 'Added style, lighting, composition, city details',
'v1_to_v2': 'Fixed raincoat color, fixed walking direction, added face constraint'
}
print('Changelog:', changelog)비교를 위한 고정 시드 사용
프롬프트 변형을 비교할 때는 유일한 변수로 프롬프트 변경만 남도록 고정된 무작위 시드를 사용하세요. 고정된 시드가 없으면 출력 변화가 프롬프트를 수정했기 때문인지 무작위성 때문인지 알 수 없습니다.
import requests
SD_API_URL = 'http://localhost:7860/sdapi/v1/txt2img'
def compare_prompt_versions(prompts_dict, negative='blurry, low quality',
seed=12345, steps=30):
results = {}
for version, prompt in prompts_dict.items():
payload = {
'prompt': prompt,
'negative_prompt': negative,
'seed': seed, # FIXED SEED for fair comparison
'steps': steps,
'cfg_scale': 7,
'width': 512,
'height': 512
}
response = requests.post(SD_API_URL, json=payload)
results[version] = response.json().get('images', [None])[0]
print(f'{version}: generated with seed {seed}')
return results
promptvariants = {
'v0': 'a woman walking in a rainy city at night',
'v1': 'cinematic, rainy Tokyo night, yellow raincoat, neon reflections',
'v2': 'BRIGHT YELLOW raincoat, facing camera, cinematic Tokyo rain night'
}
# compare_prompt_versions(prompt_variants, seed=42)빼기 방식
반복을 여러 번 거치면 프롬프트가 지나치게 부풀어 오를 수 있습니다. 빼기 방식은 상세한 프롬프트에서 시작하여 용어를 하나씩 제거하면서 실제로 효과를 내는 용어와 단지 잡음을 더하는 용어를 확인합니다.
# Start with a detailed prompt
full_prompt = (
'young woman, yellow raincoat, Tokyo, rain, neon, night, '
'street photography, cinematic, bokeh, wet pavement, '
'medium shot, warm tones, highly detailed, 8K, masterpiece, '
'award winning, beautiful, stunning, gorgeous'
)
# Remove terms and test if output quality degrades
test_removed = [
'masterpiece, award winning, beautiful, stunning, gorgeous', # quality tokens
'8K, highly detailed', # resolution tokens
'wet pavement', # specific detail
'cinematic', # style term
]
# Results typically show:
# - Generic quality tokens (masterpiece, beautiful) have minimal effect
# - Specific scene details (wet pavement, neon) matter most
# - Remove token: if output unchanged, that term is not contributing
print('Subtractive testing: remove terms and observe impact')
print('Terms that do not change output when removed can be discarded')
print('This produces lean, effective prompts')특정 실패 유형에 대한 개선
이미지 generation에서 흔히 발생하는 각 실패 유형에는 알려진 해결 방법이 있습니다. 이 지식을 체계적인 확인 목록에 포함하면 개선 작업을 더 빠르게 진행할 수 있습니다.
FAILURE_FIXES = {
'Extra or deformed fingers': [
'Add to negative: extra fingers, deformed hands, bad anatomy',
'Add to positive: perfect hands, anatomically correct',
'Use inpainting to fix the specific area'
],
'Text artifacts / watermarks': [
'Add to negative: watermark, text, signature, logo',
'Increase CFG scale slightly',
'Use a different model checkpoint'
],
'Wrong style (cartoonish when photo expected)': [
'Add to negative: cartoon, anime, illustration, painted',
'Add to positive: photorealistic, DSLR, film photography',
'Use a photorealism-focused checkpoint'
],
'Background too busy / distracting': [
'Add to positive: simple background, clean background, blurred background',
'Add: shallow depth of field, bokeh background',
'Add to negative: cluttered background, busy background'
],
'Wrong color (model ignores color spec)': [
'Emphasize color: BRIGHT RED (caps), crimson red, deep scarlet',
'Add color to multiple places in prompt',
'Use img2img with a color reference image'
]
}
for failure, fixes in list(FAILURE_FIXES.items())[:3]:
print(f'\nISSUE: {failure}')
for fix in fixes:
print(f' FIX: {fix}')이미지 generation을 위한 프롬프트 버전 관리
프롬프트 버전과 그 출력을 체계적으로 추적하세요. 이렇게 하면 향후 프로젝트를 위한 참조 라이브러리가 만들어지고, 특정 주제와 스타일에 효과적인 방법의 패턴을 발견할 수 있습니다.
import json
from datetime import datetime
from pathlib import Path
def save_refinement_session(session_name, iterations, output_dir='prompt_sessions'):
Path(output_dir).mkdir(exist_ok=True)
session_data = {
'name': session_name,
'created': datetime.now().isoformat(),
'iterations': iterations
}
filepath = f'{output_dir}/{session_name}.json'
with open(filepath, 'w') as f:
json.dump(session_data, f, indent=2)
print(f'Session saved: {filepath}')
# Example session record
session = [
{
'version': 'v0',
'prompt': 'a woman walking in a rainy city at night',
'issues': ['too vague', 'no style', 'no lighting'],
'seed': 12345
},
{
'version': 'v1',
'prompt': 'young woman, yellow raincoat, Tokyo night rain, neon, cinematic',
'issues': ['raincoat not yellow', 'facing wrong way'],
'seed': 12345
},
{
'version': 'v2',
'prompt': 'BRIGHT YELLOW raincoat, facing camera, Tokyo rain, neon, cinematic',
'issues': [],
'seed': 12345,
'status': 'accepted'
}
]
save_refinement_session('tokyo_rain_woman', session)개선 예산: 반복은 몇 번 해야 하나요
개선 작업은 점점 수익이 감소합니다. 사용 사례에 따라 몇 번의 반복에 투자할지 결정하는 실용적인 기준은 다음과 같습니다:
ITERATION_BUDGET_GUIDE = {
'Quick internal mockup': {
'budget': '2-3 iterations',
'goal': 'Good enough to communicate concept',
'stopping_criteria': 'Main subject correct, rough style established'
},
'Marketing asset': {
'budget': '4-6 iterations',
'goal': 'Professional quality, brand-consistent',
'stopping_criteria': 'Color, style, composition match brief exactly'
},
'Hero image / campaign visual': {
'budget': '8-12 iterations + final manual touchup',
'goal': 'Publication quality, no visible artifacts',
'stopping_criteria': 'Zero artifacts, passes creative director review'
},
'Generative art piece': {
'budget': 'Unlimited — creative exploration',
'goal': 'Discover unexpected aesthetic direction',
'stopping_criteria': 'Emotional resonance with creator\'s intent'
}
}
for use_case, guide in ITERATION_BUDGET_GUIDE.items():
print(f'{use_case}: {guide["budget"]}')
print(f' Stop when: {guide["stopping_criteria"]}')
print()LLM을 활용한 프롬프트 개선
텍스트 LLM을 사용하여 이미지 문제를 분석하고 프롬프트 개선안을 제안하도록 하세요. 이렇게 하면 LLM의 추론과 이미지 generation을 결합하여 메타 개선 순환 과정을 만들 수 있습니다.
import anthropic
client = anthropic.Anthropic(api_key='YOUR_API_KEY')
REFINEMENT_ADVISOR_PROMPT = '''I am generating an image with this prompt:
Current prompt: {current_prompt}
Negative prompt: {current_negative}
The image has these problems:
{issues}
Suggest specific changes to the prompt that would fix these problems.
Provide:
1. Modified positive prompt (full, ready to use)
2. Modified negative prompt (full, ready to use)
3. Explanation of each change
Keep your changes minimal — only fix the stated issues, do not redesign the image.'''
def get_refinement_suggestion(current_prompt, current_negative, issues):
response = client.messages.create(
model='claude-opus-4-5', max_tokens=1000,
messages=[{'role': 'user', 'content':
REFINEMENT_ADVISOR_PROMPT.format(
current_prompt=current_prompt,
current_negative=current_negative,
issues='\n'.join(f'- {i}' for i in issues)
)}]
)
return response.content[0].text
suggestion = get_refinement_suggestion(
current_prompt='a woman in a raincoat at night',
current_negative='blurry',
issues=['raincoat appears dark not yellow', 'background too busy']
)
print(suggestion[:300], '...')빠른 확인
이미지 프롬프트의 두 버전을 비교하여 수정으로 결과가 개선되었는지 확인하려고 합니다. 공정한 비교를 위해 무엇을 일정하게 유지해야 할까요?
반복적 개선 요약
이미지 프롬프트의 반복적 개선은 체계적으로 배우고 익힐 수 있는 기술입니다:
- 순환 과정: 생성 → 분석 → 조정 → 재생성
- 문제 분류 체계: 문제를 주제, 스타일, 조명, composition 또는 품질로 분류합니다
- 고정 시드: 항상 동일한 시드에서 프롬프트 버전을 비교합니다
- 대상 지정 수정: 파악한 구체적인 문제를 해결하고, 프롬프트 전체를 다시 작성하지 않습니다
- 빼기 방식: 실제로 기여하는 용어를 파악하기 위해 용어를 제거합니다
- 버전 추적: 각 반복마다 프롬프트, 문제, 변경 사항을 기록합니다
- 예산 인식: 목업에는 2~3회, 핵심 자산에는 8~12회의 반복을 사용합니다
자주 묻는 질문
“반복적인 이미지 프롬프트 개선” 강의는 무료인가요?
네 — “반복적인 이미지 프롬프트 개선” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 AI Prompt Engineering 강의 전체를 잠금 해제할 수 있습니다. AI Prompt Engineering 강의에는 총 4개의 강의가 포함되어 있습니다.
“반복적인 이미지 프롬프트 개선”에서 뭘 배우나요?
생성된 이미지를 분석하고 프롬프트를 체계적으로 조정합니다. 브라우저에서 직접 실행하는 실습 코드로 AI Prompt Engineering을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
AI Prompt Engineering을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 AI Prompt Engineering은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.
“반복적인 이미지 프롬프트 개선” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 AI Prompt Engineering 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 AI Prompt Engineering 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 이미지 생성 프롬프트의 구조
- 스타일 및 예술 매체 지정
- 네거티브 프롬프트와 제외 항목
- 반복적인 이미지 프롬프트 개선