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>
172 lines
6.1 KiB
Markdown
172 lines
6.1 KiB
Markdown
---
|
|
id: wiki-2026-0508-부정-프롬프트와-가중치를-활용한-시각적-아티팩트-artif
|
|
title: 부정 프롬프트와 가중치를 활용한 시각적 아티팩트(Artifact) 디버깅 및 제어
|
|
category: 10_Wiki/Topics
|
|
status: verified
|
|
canonical_id: self
|
|
aliases: [Negative Prompt, Prompt Weighting, Artifact Debugging]
|
|
duplicate_of: none
|
|
source_trust_level: A
|
|
confidence_score: 0.9
|
|
verification_status: applied
|
|
tags: [diffusion, prompt-engineering, sdxl, flux, image-gen]
|
|
raw_sources: []
|
|
last_reinforced: 2026-05-10
|
|
github_commit: pending
|
|
tech_stack:
|
|
language: python
|
|
framework: diffusers
|
|
---
|
|
|
|
# 부정 프롬프트와 가중치를 활용한 시각적 아티팩트(Artifact) 디버깅 및 제어
|
|
|
|
## 매 한 줄
|
|
> **"매 artifact 매 unwanted concept 의 누출"**. Diffusion model 의 산출물 의 extra fingers, melted face, watermark 의 매 negative prompt + token weighting 의 conditional vector 조정 의 억제. 매 2026 의 FLUX 매 negative prompt 의존도 ↓ — guidance distillation 으로 quality 자체 ↑.
|
|
|
|
## 매 핵심
|
|
|
|
### 매 메커니즘
|
|
- Classifier-Free Guidance (CFG): `noise = uncond + scale * (cond - uncond)`.
|
|
- Negative prompt 의 `uncond` 의 대체 — 매 "이쪽 으로 가지 마" vector.
|
|
- Token weighting (`(token:1.3)`) 매 cross-attention 의 token embedding scale.
|
|
|
|
### 매 흔한 artifact
|
|
- **Anatomy**: extra fingers, deformed hands, asymmetric eyes.
|
|
- **Composition**: cropped head, floating limbs, tangent edges.
|
|
- **Quality**: blur, jpeg artifact, low resolution, oversaturation.
|
|
- **Concept leak**: text/watermark, signature, logo.
|
|
|
|
### 매 응용
|
|
1. SDXL/SD3 매 negative prompt 의 default workflow 에 포함.
|
|
2. FLUX/SD3.5 매 prompt weighting 의존도 ↓ — guidance distilled.
|
|
3. Inpainting fix — masked region 만 negative prompt 의 적용.
|
|
|
|
## 💻 패턴
|
|
|
|
### diffusers — negative prompt 기본
|
|
```python
|
|
from diffusers import StableDiffusionXLPipeline
|
|
import torch
|
|
|
|
pipe = StableDiffusionXLPipeline.from_pretrained(
|
|
"stabilityai/stable-diffusion-xl-base-1.0",
|
|
torch_dtype=torch.float16
|
|
).to("cuda")
|
|
|
|
img = pipe(
|
|
prompt="portrait of a woman, studio light, sharp focus, 50mm lens",
|
|
negative_prompt=(
|
|
"deformed, extra fingers, mutated hands, asymmetric eyes, "
|
|
"lowres, jpeg artifacts, watermark, signature, text, blurry"
|
|
),
|
|
guidance_scale=7.0,
|
|
num_inference_steps=30,
|
|
).images[0]
|
|
```
|
|
|
|
### compel — token weighting (SDXL)
|
|
```python
|
|
from compel import Compel, ReturnedEmbeddingsType
|
|
|
|
compel = Compel(
|
|
tokenizer=[pipe.tokenizer, pipe.tokenizer_2],
|
|
text_encoder=[pipe.text_encoder, pipe.text_encoder_2],
|
|
returned_embeddings_type=ReturnedEmbeddingsType.PENULTIMATE_HIDDEN_STATES_NON_NORMALIZED,
|
|
requires_pooled=[False, True],
|
|
)
|
|
|
|
prompt = "a (majestic:1.3) lion, (golden mane:1.2), (cinematic:0.8)"
|
|
neg = "(cartoon:1.4), (anime:1.4), (3d render:1.2)"
|
|
|
|
embeds, pooled = compel(prompt)
|
|
neg_embeds, neg_pooled = compel(neg)
|
|
|
|
img = pipe(
|
|
prompt_embeds=embeds, pooled_prompt_embeds=pooled,
|
|
negative_prompt_embeds=neg_embeds, negative_pooled_prompt_embeds=neg_pooled,
|
|
).images[0]
|
|
```
|
|
|
|
### A1111 syntax (community standard)
|
|
```text
|
|
# 매 강조 — (token:weight)
|
|
masterpiece, (intricate details:1.2), (sharp focus:1.1)
|
|
|
|
# Negative
|
|
(worst quality:1.4), (low quality:1.4), (extra digits:1.3),
|
|
(bad hands:1.3), watermark, text
|
|
```
|
|
|
|
### FLUX — minimal negative
|
|
```python
|
|
# FLUX.1 [dev] 매 distilled — CFG ≈ 1, negative prompt 효과 ↓
|
|
from diffusers import FluxPipeline
|
|
|
|
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16).to("cuda")
|
|
img = pipe(
|
|
prompt="cinematic portrait, golden hour, shallow DOF",
|
|
guidance_scale=3.5, # FLUX-specific
|
|
num_inference_steps=28,
|
|
).images[0]
|
|
# 매 negative prompt 매 관습 의 대신 — positive prompt 의 specificity 의 의존
|
|
```
|
|
|
|
### Region-specific negative (regional prompter)
|
|
```python
|
|
# 매 ComfyUI / Forge — mask 별 negative
|
|
region_prompts = [
|
|
{"mask": face_mask, "neg": "deformed, extra eye, asymmetric"},
|
|
{"mask": hand_mask, "neg": "extra fingers, fused fingers, mutated"},
|
|
]
|
|
```
|
|
|
|
### Artifact debug — A/B isolate
|
|
```python
|
|
# 매 baseline (no negative)
|
|
img_base = pipe(prompt=p, negative_prompt="", seed=42).images[0]
|
|
|
|
# 매 add one term at a time
|
|
for term in ["deformed", "extra fingers", "lowres", "watermark"]:
|
|
img = pipe(prompt=p, negative_prompt=term, seed=42).images[0]
|
|
img.save(f"debug_{term}.png")
|
|
# 매 비교 의 어떤 term 의 효과 의 식별
|
|
```
|
|
|
|
## 매 결정 기준
|
|
| 상황 | Approach |
|
|
|---|---|
|
|
| Hand artifact | `(bad hands:1.3), extra fingers, fused fingers` |
|
|
| Watermark/text | `watermark, signature, text, logo` (high weight) |
|
|
| Style leak (cartoon) | `(cartoon:1.4), (anime:1.4)` |
|
|
| FLUX/SD3.5 사용 | negative prompt 의 minimal — positive 의 specificity ↑ |
|
|
| Inpaint 의 fix | mask region 의 local negative |
|
|
|
|
**기본값**: SDXL → standard negative bundle + weighting; FLUX → positive prompt 의 specificity.
|
|
|
|
## 🔗 Graph
|
|
- 부모: [[AI 이미지 생성 (AI Image Generation)]] · [[Diffusion Models]]
|
|
- 변형: [[Classifier-Free Guidance]] · [[Prompt Weighting]]
|
|
- 응용: [[AI 이미지 품질 최적화 및 디버깅 (Image Quality Optimization & Debugging)]] · [[미드저니 및 스테이블 디퓨전의 부분 편집 기법]]
|
|
- Adjacent: [[ControlNet]] · [[IP-Adapter]]
|
|
|
|
## 🤖 LLM 활용
|
|
**언제**: anatomy/composition artifact 추적, prompt A/B isolate, style leak 차단.
|
|
**언제 X**: FLUX-class distilled model — negative prompt 효과 ↓, positive specificity 의 의존.
|
|
|
|
## ❌ 안티패턴
|
|
- **Negative prompt 200-token wall**: token budget 낭비, 효과 saturate.
|
|
- **High weight (>1.5)**: 매 collapse — output 의 distort.
|
|
- **Generic "ugly, bad"**: 매 의미 없음 — concrete artifact name 의 사용.
|
|
- **FLUX 의 SDXL-style negative**: 매 non-effect — guidance distilled.
|
|
- **Seed 변경 의 비교**: 매 무의미 — same seed 만 isolate.
|
|
|
|
## 🧪 검증 / 중복
|
|
- Verified (Diffusers docs, compel library, AUTOMATIC1111 wiki, FLUX.1 model card 2024-2026).
|
|
- 신뢰도 A.
|
|
|
|
## 🕓 Changelog
|
|
| 날짜 | 변경 |
|
|
|---|---|
|
|
| 2026-05-08 | Phase 1 |
|
|
| 2026-05-10 | Manual cleanup — negative prompt + weighting, FLUX 차이 |
|