docs(10_Wiki): Topic_Business/General/Graphic/Programming을 Topics/ 하위로 이동

최상위 10_Wiki/Topic_*였던 4개 카테고리 폴더를 10_Wiki/Topics/Topic_* 로 재배치.
콘텐츠 변경 없음(순수 폴더 이동) — Topics/ 하위 나머지 폴더는 이미 지난 커밋에서
전부 정리된 상태(잔존 항목은 에이전트 운영 상태 및 사용자가 보존을 요청한
업데이트0615/무제 3.canvas 뿐).
This commit is contained in:
Antigravity Agent
2026-07-05 00:44:01 +09:00
parent e9cbf23ab5
commit 9a135bd19d
6127 changed files with 0 additions and 0 deletions
@@ -0,0 +1,198 @@
---
id: wiki-2026-0508-image-parameters
title: Image Parameters
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Image Generation Parameters, Diffusion Parameters, Sampler Settings]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [diffusion, image-generation, stable-diffusion, sampler, cfg, seed]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: python
framework: diffusers
---
# Image Parameters
## 매 한 줄
> **"매 같은 prompt 라도 sampler / steps / CFG / seed 가 그림을 결정한다"**. Diffusion-based 이미지 생성의 결과는 prompt 만큼이나 sampler 종류, sampling steps, classifier-free guidance scale, seed, scheduler 같은 운영 파라미터에 의해 좌우되며, 2026 현재 SDXL/FLUX/SD3.5/Imagen 모든 모델에서 공통적으로 적용된다.
## 매 핵심
### 매 핵심 파라미터
- **prompt / negative_prompt**: 텍스트 조건. 길이 ≠ 품질.
- **steps (sampling steps)**: 보통 20-50. FLUX-schnell 는 4 steps, Turbo/LCM 은 1-4.
- **CFG scale (guidance_scale)**: 1.5 (창의) ~ 12 (충실). FLUX 는 distilled — guidance 1 권장.
- **sampler / scheduler**: Euler, DPM++ 2M Karras, UniPC, DDIM, LCM.
- **seed**: 동일 seed + 동일 파라미터 → 재현.
- **width/height**: SDXL 1024², SD3.5 1024², FLUX 1024² 또는 1024×1536.
- **strength (img2img)**: 0 (원본) ~ 1 (전부 새로).
- **clip_skip**: 1 (기본) — anime 모델은 2 가 흔함.
- **prompt weighting**: `(word:1.3)`, `[word]` (A1111), `(word)+` (compel).
- **LoRA scale**: 0.6-0.9 일반, 1.0 강함.
### 매 sampler 비교 (2026)
- **Euler / Euler a**: 빠름, 단순.
- **DPM++ 2M Karras**: 표준 추천 — 품질/속도 균형.
- **UniPC**: 적은 steps 에서 강함.
- **DDIM**: deterministic, 재현성 좋음.
- **LCM / Turbo**: distilled, 1-4 steps.
- **Heun, DPM++ SDE**: 고품질, 느림.
### 매 응용
1. ComfyUI / A1111 / Forge UI 워크플로 작성.
2. SDK 기반 batch 생성 (diffusers).
3. ControlNet / IP-Adapter 결합.
4. 프로덕션 API (Replicate, Fal, RunPod).
## 💻 패턴
### 1. diffusers — 기본 SDXL 호출
```python
from diffusers import StableDiffusionXLPipeline
import torch
pipe = StableDiffusionXLPipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
torch_dtype=torch.float16, variant="fp16",
).to("cuda")
img = pipe(
prompt="a photo of a Shiba Inu, cinematic, 50mm",
negative_prompt="lowres, watermark",
num_inference_steps=30, guidance_scale=6.0,
width=1024, height=1024,
generator=torch.Generator("cuda").manual_seed(42),
).images[0]
img.save("out.png")
```
### 2. FLUX (guidance-distilled)
```python
from diffusers import FluxPipeline
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16).to("cuda")
img = pipe(
prompt="a tiny astronaut riding a duck, studio light",
guidance_scale=3.5, # FLUX-dev: 3-5
num_inference_steps=28,
height=1024, width=1024,
generator=torch.Generator("cuda").manual_seed(0),
).images[0]
```
### 3. LCM 1-4 steps (real-time)
```python
from diffusers import AutoPipelineForText2Image, LCMScheduler
pipe = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16).to("cuda")
img = pipe(prompt="cyberpunk cat", num_inference_steps=2, guidance_scale=0.0).images[0]
```
### 4. img2img + strength
```python
from diffusers import StableDiffusionXLImg2ImgPipeline
pipe = StableDiffusionXLImg2ImgPipeline.from_pretrained(...).to("cuda")
img = pipe(prompt=prompt, image=init, strength=0.55, guidance_scale=7.0, num_inference_steps=40).images[0]
```
### 5. prompt weighting (compel)
```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 (red:1.4) sports car, (sunset:1.2)"
conditioning, pooled = compel(prompt)
img = pipe(prompt_embeds=conditioning, pooled_prompt_embeds=pooled, num_inference_steps=30).images[0]
```
### 6. LoRA + scale
```python
pipe.load_lora_weights("path/to/anime.safetensors", adapter_name="anime")
pipe.set_adapters(["anime"], adapter_weights=[0.7])
img = pipe(prompt="anime girl, blue hair", num_inference_steps=30, guidance_scale=6.5).images[0]
```
### 7. ControlNet (구조 보존)
```python
from diffusers import StableDiffusionXLControlNetPipeline, ControlNetModel
cnet = ControlNetModel.from_pretrained("diffusers/controlnet-canny-sdxl-1.0", torch_dtype=torch.float16)
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0", controlnet=cnet, torch_dtype=torch.float16,
).to("cuda")
img = pipe(prompt="oil painting", image=canny_img,
controlnet_conditioning_scale=0.7, num_inference_steps=30).images[0]
```
### 8. seed sweep (탐색)
```python
import torch, itertools
for seed, cfg in itertools.product([0,1,2,3], [4.0, 6.0, 8.0]):
g = torch.Generator("cuda").manual_seed(seed)
img = pipe(prompt=prompt, guidance_scale=cfg, generator=g).images[0]
img.save(f"seed{seed}_cfg{cfg}.png")
```
### 9. scheduler 교체
```python
from diffusers import DPMSolverMultistepScheduler
pipe.scheduler = DPMSolverMultistepScheduler.from_config(
pipe.scheduler.config, algorithm_type="dpmsolver++", use_karras_sigmas=True,
)
```
### 10. ComfyUI API workflow (JSON 단편)
```json
{
"3": { "class_type": "KSampler",
"inputs": { "seed": 42, "steps": 30, "cfg": 6.5,
"sampler_name": "dpmpp_2m_sde", "scheduler": "karras",
"denoise": 1.0, "model": ["4",0], "positive": ["6",0],
"negative": ["7",0], "latent_image": ["5",0] } }
}
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| SDXL 기본 | DPM++ 2M Karras, 30 steps, CFG 6-7 |
| FLUX-dev | Euler, 28 steps, guidance 3.5 |
| FLUX-schnell / Turbo / LCM | Euler, 1-4 steps, guidance 0 |
| 사진 사실성 | CFG 4-6, negative_prompt 충실 |
| 스타일 강조 | LoRA 0.7-0.9 + CFG 6-8 |
| 구조 고정 | ControlNet, scale 0.6-0.8 |
| 배치 탐색 | seed sweep + grid |
**기본값**: SDXL = DPM++ 2M Karras, 30 steps, CFG 6.5. FLUX-dev = Euler, 28 steps, guidance 3.5.
## 🔗 Graph
- 부모: [[Diffusion-Models]] · [[Generative-AI]]
- 변형: [[Prompt Weighting]]
- 응용: [[ControlNet]] · [[LoRA]] · [[IP-Adapter]]
- Adjacent: [[Stable-Diffusion]] · [[FLUX]] · [[ComfyUI]]
## 🤖 LLM 활용
**언제**: 파라미터 매핑 (UI ↔ API), prompt → weighted prompt 변환, sampler 선택 가이드, batch grid 코드 생성.
**언제 X**: 모델별 quirk (예: SD3.5 의 specific shift) — 모델 카드 직접 확인.
## ❌ 안티패턴
- **CFG 무작정 12 이상**: burn-out, oversaturated.
- **steps 100+**: 30-50 이후 거의 무차이, 비용만 증가.
- **FLUX 에 CFG 7**: distilled — guidance 1-4 가 정상.
- **seed 미고정 디버깅**: 재현 불가 → 파라미터 영향 분석 불가.
- **Negative prompt 남용**: SDXL/FLUX 는 짧게, 또는 비워도 OK.
- **prompt weighting 과용**: `(word:2.0)+` → broken composition.
## 🧪 검증 / 중복
- Verified (HuggingFace diffusers docs, FLUX model card, ComfyUI wiki 2026).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — sampler/CFG/LoRA/ControlNet 코드 패턴 |