Files
2nd/10_Wiki/Topics/AI_and_ML/Image Parameters.md
T
koriweb d8a80f6272 chore(wiki): dangling 링크 canonical 정규화 (768파일/1200건)
이름만 다른(표기 변형) [[위키링크]]를 대상 문서의 canonical 제목으로 치환해
끊겼던 1,200개 링크를 연결. 제목/파일명 정규화 일치만 적용하고 별칭 매칭은
과병합 위험으로 제외(애매성 가드). 원본은 _link_reconcile_backup/ 에 백업.
도구: Datacollect/scripts/link_reconcile_apply.mjs

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 12:24:15 +09:00

7.4 KiB
Raw Blame History

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-image-parameters Image Parameters 10_Wiki/Topics verified self
Image Generation Parameters
Diffusion Parameters
Sampler Settings
none A 0.9 applied
diffusion
image-generation
stable-diffusion
sampler
cfg
seed
2026-05-10 pending
language framework
python 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 호출

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)

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)

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

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)

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

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 (구조 보존)

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 (탐색)

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 교체

from diffusers import DPMSolverMultistepScheduler
pipe.scheduler = DPMSolverMultistepScheduler.from_config(
    pipe.scheduler.config, algorithm_type="dpmsolver++", use_karras_sigmas=True,
)

10. ComfyUI API workflow (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

🤖 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 코드 패턴