docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거

Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
Antigravity Agent
2026-07-05 00:33:48 +09:00
parent 1cfd3bbb56
commit 9148c358d0
6455 changed files with 1 additions and 86875 deletions
@@ -0,0 +1,211 @@
---
id: wiki-2026-0508-이미지-생성-및-제어-파이프라인
title: 이미지 생성 및 제어 파이프라인
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Image Generation Pipeline, Controlled Diffusion Pipeline, ControlNet Pipeline]
duplicate_of: none
source_trust_level: A
confidence_score: 0.92
verification_status: applied
tags: [diffusion, image-gen, controlnet, flux, comfyui]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: python
framework: PyTorch/diffusers/ComfyUI
---
# 이미지 생성 및 제어 파이프라인
## 매 한 줄
> **"매 control 은 conditioning 의 stack"**. 2026 image gen pipeline 은 base model (FLUX.1 / SDXL / SD3.5) → control adapter (ControlNet / IP-Adapter / T2I-Adapter) → LoRA → refiner 의 layered conditioning. ComfyUI 는 매 node graph 로 이를 explicit, diffusers 는 매 pipeline class 로 abstraction.
## 매 핵심
### 매 pipeline 단계
- **Prompt encoding**: T5 + CLIP encoder, dual conditioning
- **Latent init**: noise 또는 img2img latent
- **Conditioning injection**: ControlNet (structure), IP-Adapter (style ref), LoRA (concept)
- **Sampling**: Euler / DPM-Solver++ / Flow matching, 20-50 steps
- **Decoding**: VAE → pixel space, optional refiner
### 매 control modality
- **Structure**: canny, depth, pose, segmentation — 매 spatial constraint
- **Identity**: IP-Adapter Face, InstantID, PuLID — 매 face preservation
- **Style**: IP-Adapter Style, style-LoRA — 매 reference style
- **Concept**: textual inversion, custom LoRA — 매 specific subject
### 매 응용
1. Product photography 의 매 batch generation (sku × pose × bg).
2. Game asset pipeline — 매 concept → portrait → animation pose 일관성.
3. UI/UX prototyping — 매 wireframe-to-mockup conversion.
## 💻 패턴
### diffusers FLUX + ControlNet
```python
import torch
from diffusers import FluxControlNetPipeline, FluxControlNetModel
controlnet = FluxControlNetModel.from_pretrained(
"InstantX/FLUX.1-dev-Controlnet-Canny",
torch_dtype=torch.bfloat16,
)
pipe = FluxControlNetPipeline.from_pretrained(
"black-forest-labs/FLUX.1-dev",
controlnet=controlnet,
torch_dtype=torch.bfloat16,
).to("cuda")
image = pipe(
prompt="cyberpunk samurai, neon rain",
control_image=canny_image,
controlnet_conditioning_scale=0.7,
num_inference_steps=28,
guidance_scale=3.5,
).images[0]
```
### Multi-ControlNet stacking
```python
from diffusers import StableDiffusionXLControlNetPipeline, ControlNetModel
cn_pose = ControlNetModel.from_pretrained("xinsir/controlnet-openpose-sdxl-1.0")
cn_depth = ControlNetModel.from_pretrained("diffusers/controlnet-depth-sdxl-1.0")
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
controlnet=[cn_pose, cn_depth],
torch_dtype=torch.float16,
).to("cuda")
result = pipe(
prompt="warrior pose, mountain backdrop",
image=[pose_img, depth_img],
controlnet_conditioning_scale=[0.8, 0.5],
num_inference_steps=30,
).images[0]
```
### IP-Adapter style transfer
```python
pipe.load_ip_adapter(
"h94/IP-Adapter",
subfolder="sdxl_models",
weight_name="ip-adapter-plus_sdxl_vit-h.safetensors",
)
pipe.set_ip_adapter_scale(0.6)
out = pipe(
prompt="portrait of a knight",
ip_adapter_image=style_reference,
num_inference_steps=30,
).images[0]
```
### LoRA composition
```python
pipe.load_lora_weights("lora_pack/", weight_name="anime_style.safetensors", adapter_name="anime")
pipe.load_lora_weights("lora_pack/", weight_name="my_character.safetensors", adapter_name="char")
pipe.set_adapters(["anime", "char"], adapter_weights=[0.7, 0.9])
img = pipe(prompt="my character in anime style, school uniform").images[0]
```
### Img2img refinement
```python
from diffusers import AutoPipelineForImage2Image
refiner = AutoPipelineForImage2Image.from_pretrained(
"stabilityai/stable-diffusion-xl-refiner-1.0",
torch_dtype=torch.float16,
).to("cuda")
refined = refiner(
prompt=prompt,
image=base_image,
strength=0.3,
num_inference_steps=20,
).images[0]
```
### ComfyUI API workflow
```python
import json, urllib.request
workflow = json.load(open("workflows/portrait_pipeline.json"))
workflow["6"]["inputs"]["text"] = "cyberpunk samurai"
workflow["12"]["inputs"]["seed"] = 12345
req = urllib.request.Request(
"http://127.0.0.1:8188/prompt",
data=json.dumps({"prompt": workflow}).encode(),
headers={"Content-Type": "application/json"},
)
resp = urllib.request.urlopen(req).read()
print(resp)
```
### Batch pipeline with caching
```python
from functools import lru_cache
@lru_cache(maxsize=8)
def encode_prompt(prompt: str):
return pipe.encode_prompt(prompt, device="cuda")
def generate_batch(prompts: list[str], control_imgs: list, seeds: list[int]):
results = []
for p, c, s in zip(prompts, control_imgs, seeds):
embeds = encode_prompt(p)
gen = torch.Generator("cuda").manual_seed(s)
img = pipe(
prompt_embeds=embeds[0],
pooled_prompt_embeds=embeds[1],
control_image=c,
generator=gen,
).images[0]
results.append(img)
return results
```
## 매 결정 기준
| 상황 | Pipeline |
|---|---|
| Highest fidelity, slow | FLUX.1-dev + ControlNet + refiner |
| Real-time / interactive | SDXL Turbo / FLUX Schnell, 4-8 steps |
| Face consistency | InstantID / PuLID + IP-Adapter Face |
| Style consistency batch | Style-LoRA + fixed seed offset |
| Local-only (Apple Silicon) | MLX + SDXL or DrawThings, FLUX.1 quantized |
**기본값**: FLUX.1-dev + 1 ControlNet (canny/depth) + IP-Adapter, 28 steps, guidance 3.5.
## 🔗 Graph
- 부모: [[AI 이미지 생성 (AI Image Generation)]] · [[Diffusion_Models]]
- 변형: [[초상화 및 애니메이션 스타일 제어]] · [[ComfyUI]]
- 응용: [[AI 이미지 생성 및 편집 워크플로우 (AI Image Generation & Editing Workflow)]] · [[AI 이미지 품질 최적화 및 디버깅 (Image Quality Optimization & Debugging)]]
- Adjacent: [[ControlNet]] · [[LoRA]] · [[FLUX]]
## 🤖 LLM 활용
**언제**: prompt rewriting, control image 의 caption 추출, workflow JSON 생성, error diagnosis.
**언제 X**: VAE/UNet 의 inner forward — 매 결정론적, LLM 의 X.
## ❌ 안티패턴
- **Conditioning over-stack**: 매 5+ control 동시 — 매 conflict, blurry output.
- **CFG too high (>7 on FLUX)**: oversaturated, plastic.
- **LoRA stacking without weight tuning**: 매 incompatible concept blend.
- **Missing seed control**: 매 batch 마다 random — 재현성 손실.
- **VAE mismatch**: 매 model VAE 와 다른 VAE 사용 → color shift.
## 🧪 검증 / 중복
- Verified (diffusers 0.30+, ComfyUI 2026-04, FLUX.1 model card).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — image gen pipeline + control modalities |