f8b21af4be
10_Wiki/Topics 대규모 정리: - 오류 캡처/미완성 stub 문서 227개 제거 - 교차폴더 중복 43클러스터 병합 (63파일 → redirect) - 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건 - 카테고리 MOC 6개 신규 생성 - Graph 섹션 미해결 related-keyword 링크 10,058건 제거 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6.8 KiB
6.8 KiB
id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
| id | title | category | status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | verification_status | tags | raw_sources | last_reinforced | github_commit | tech_stack | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| wiki-2026-0508-negative-prompt | Negative Prompt | 10_Wiki/Topics | verified | self |
|
none | A | 0.92 | applied |
|
2026-05-10 | pending |
|
한 줄
Negative prompt는 이미지 생성 모델에 "포함되지 말아야 할" 개념을 명시하여 classifier-free guidance(CFG) 분기에서 해당 방향으로부터 멀어지게 유도하는 텍스트 입력이다.
핵심
작동 원리 (Stable Diffusion)
- Diffusion model은 매 step에서 noise prediction을 수행한다.
- CFG는 두 분기를 결합한다: conditional (positive prompt) + unconditional (empty / negative prompt).
- 공식:
eps = eps_uncond + cfg_scale * (eps_cond - eps_uncond). - Negative prompt를 사용하면
eps_uncond자리에 negative prompt embedding을 넣어, 결과를 negative 방향에서 멀어지게 한다. - CFG scale이 높을수록 negative 효과가 강해진다 (보통 7~12).
Midjourney --no
--no blurry, text, watermark형식으로 prompt 끝에 추가.- 내부적으로 weighted negative prompt와 유사한 방식으로 처리.
- v6 이후 더 정교하게 작동.
Weighting / Attention
- Stable Diffusion WebUI:
(blurry:1.4),[bad anatomy:0.7]로 weight 조정. ((extra fingers))같은 괄호 중첩으로 강조 (×1.1 per pair).
흔한 negative tokens
- 품질:
low quality, worst quality, blurry, jpeg artifacts, lowres - 해부학:
bad anatomy, extra fingers, malformed limbs, missing arms - 텍스트:
text, watermark, signature, logo - 스타일:
cartoon, anime, 3d render(사진 스타일 원할 때)
응용
- 사진 사실성 향상 (illustration 제거)
- NSFW / 폭력 방지 (safety negative)
- 손가락 / 얼굴 결함 보정
- 특정 색상 / 구도 회피
💻 패턴
# 1. diffusers 라이브러리 — 기본 negative prompt
from diffusers import StableDiffusionPipeline
import torch
pipe = StableDiffusionPipeline.from_pretrained(
"stabilityai/stable-diffusion-2-1",
torch_dtype=torch.float16,
).to("cuda")
image = pipe(
prompt="a photorealistic portrait of a woman, natural lighting, 8k",
negative_prompt="blurry, low quality, cartoon, deformed, extra limbs, watermark",
num_inference_steps=30,
guidance_scale=7.5,
).images[0]
# 2. SDXL — dual text encoder, 별도 negative prompt 2개
from diffusers import StableDiffusionXLPipeline
pipe = StableDiffusionXLPipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16
).to("cuda")
image = pipe(
prompt="cinematic photo of a samurai in rain",
prompt_2="dramatic lighting, ultra detailed",
negative_prompt="cartoon, anime, low quality, blurry",
negative_prompt_2="text, watermark, signature",
).images[0]
# 3. ComfyUI / API — weighted negative
negative = "(low quality:1.3), (bad anatomy:1.4), (extra fingers:1.5), watermark, text"
# 4. Midjourney --no 플래그
/imagine prompt: a serene japanese garden at dusk --no people, text, watermark --ar 16:9 --v 6
# 5. Embeddings 기반 negative (Textual Inversion)
# EasyNegative, BadDream 같은 학습된 embedding 활용
negative_prompt = "easynegative, badhandv4, (worst quality:1.2)"
# 텍스트 인코더가 학습된 token으로 매핑
# 6. 동적 negative — 사용자 선호 학습
def build_negative(user_dislikes: list[str]) -> str:
base = ["blurry", "low quality", "watermark"]
return ", ".join(base + user_dislikes)
negative_prompt = build_negative(["cartoon", "people"])
# 7. ControlNet + negative
from diffusers import StableDiffusionControlNetPipeline, ControlNetModel
controlnet = ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-canny")
pipe = StableDiffusionControlNetPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float16
).to("cuda")
image = pipe(
prompt="a futuristic city",
negative_prompt="blurry, low res, oversaturated",
image=canny_edges,
).images[0]
# 8. CFG scale 동적 조절 — negative 영향력 강화
image = pipe(
prompt="...", negative_prompt="...",
guidance_scale=12.0, # 7.5 → 12.0: negative 효과 강화
).images[0]
# 9. Region-specific negative (Regional Prompter)
# 이미지 영역별 다른 negative 적용 (얼굴 영역만 anatomy negative)
# 10. Automatic negative — LLM이 prompt에서 추론
def auto_negative(positive: str, llm) -> str:
return llm.complete(f"Given prompt '{positive}', list undesired artifacts: ")
결정 기준
| 상황 | 추천 |
|---|---|
| 사진 사실성 | cartoon, anime, illustration, 3d 제외 |
| 손/얼굴 결함 | bad anatomy, extra fingers, deformed + EasyNegative embedding |
| 텍스트 노이즈 | text, watermark, signature, logo |
| CFG 7~9 (기본) | negative 적당히 작동 |
| CFG 11~13 | negative 강하게, 그러나 saturation 위험 |
| Midjourney v6 | --no 짧고 명시적으로 |
| SDXL | 두 encoder 모두에 negative 분리 권장 |
| ComfyUI | weighted syntax (token:1.3) 활용 |
기본값: blurry, low quality, watermark, bad anatomy + CFG 7.5.
🔗 Graph
- 부모: AI 이미지 생성 (AI Image Generation), Prompt_Engineering, Stable-Diffusion
- 형제: Classifier-Free-Guidance, ControlNet, LoRA
- 응용: AI-Art
🤖 LLM 활용
- LLM이 사용자의 positive prompt를 분석해 적절한 negative prompt 자동 생성.
- ChatGPT / Claude로 "이 이미지 스타일에 맞는 negative prompt 추천" 요청.
- Vision LLM이 생성 결과를 평가하여 다음 generation의 negative를 강화 (RLHF 유사 루프).
❌ 안티패턴
- Negative에 너무 많은 토큰 나열 → 모델 혼란, 의도치 않은 영향. 10~15개 이내 권장.
- Positive와 모순되는 negative (e.g., positive
dog, negativeanimal). - CFG scale 너무 높이기 → 색상 saturation, 디테일 손실.
- 학습되지 않은 추상어 사용 (
bad,ugly만 단독으로 — 효과 약함).
🧪 검증 / 중복
- 중복 문서:
Negative_Prompts.md→ REDIRECT 처리. - 동일 개념: Anti-Prompt, Exclusion-Prompt (별칭 통합).
- 검증: A/B 테스트 (negative 유무로 동일 seed 비교)로 효과 측정.
🕓 Changelog
- Phase 1 (2026-05-08): 초기 생성.
- Manual cleanup (2026-05-10): canonical 확정, 패턴 10개 정비, SDXL dual encoder / Midjourney v6 추가, 별칭 통합.