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:
@@ -0,0 +1,196 @@
|
||||
---
|
||||
id: wiki-2026-0508-미드저니-및-스테이블-디퓨전의-부분-편집-기법
|
||||
title: 미드저니 및 스테이블 디퓨전의 부분 편집 기법
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [Inpainting, Outpainting, Vary Region, Partial Edit]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [diffusion, inpainting, midjourney, sdxl, flux]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: python
|
||||
framework: diffusers
|
||||
---
|
||||
|
||||
# 미드저니 및 스테이블 디퓨전의 부분 편집 기법
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 부분 편집 매 mask × prompt × denoise 의 3축 control"**. Inpainting/outpainting 매 image 의 일부 만 regenerate — 매 mask region 의 latent 의 noise 의 추가 후 conditional denoise. 매 2026 의 FLUX.1 Fill, SDXL Inpaint, MJ "Vary Region" / "Vary Subtle" 매 production-ready.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 3가지 mode
|
||||
- **Inpainting**: existing region 의 mask 의 그리고 prompt 로 replace.
|
||||
- **Outpainting**: image 의 canvas 의 확장 의 새 region 의 채움.
|
||||
- **Vary Region (MJ)**: subset 의 selective regeneration — context-aware.
|
||||
|
||||
### 매 control axis
|
||||
- **Mask shape**: hard edge vs feathered (blur radius).
|
||||
- **Denoise strength**: 0.3 (subtle tweak) — 1.0 (full replace).
|
||||
- **Prompt scope**: full-image prompt vs masked-only prompt.
|
||||
|
||||
### 매 응용
|
||||
1. Object 추가/제거 — 매 background 의 보존 의 selective replace.
|
||||
2. Outpaint 의 wide aspect — 16:9 → 21:9 cinematic.
|
||||
3. Face/hand fix — adetailer 의 auto-detect mask + inpaint pass.
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### SDXL Inpaint pipeline
|
||||
```python
|
||||
from diffusers import StableDiffusionXLInpaintPipeline
|
||||
from PIL import Image
|
||||
import torch
|
||||
|
||||
pipe = StableDiffusionXLInpaintPipeline.from_pretrained(
|
||||
"diffusers/stable-diffusion-xl-1.0-inpainting-0.1",
|
||||
torch_dtype=torch.float16,
|
||||
).to("cuda")
|
||||
|
||||
img = Image.open("photo.png").convert("RGB")
|
||||
mask = Image.open("mask.png").convert("L") # white = replace, black = keep
|
||||
|
||||
result = pipe(
|
||||
prompt="a red ceramic vase with white flowers",
|
||||
image=img,
|
||||
mask_image=mask,
|
||||
strength=0.95, # full replace inside mask
|
||||
guidance_scale=7.0,
|
||||
num_inference_steps=30,
|
||||
).images[0]
|
||||
```
|
||||
|
||||
### FLUX.1 Fill (2024-2026 SOTA)
|
||||
```python
|
||||
from diffusers import FluxFillPipeline
|
||||
|
||||
pipe = FluxFillPipeline.from_pretrained(
|
||||
"black-forest-labs/FLUX.1-Fill-dev",
|
||||
torch_dtype=torch.bfloat16,
|
||||
).to("cuda")
|
||||
|
||||
result = pipe(
|
||||
prompt="a vintage brass lamp on the desk",
|
||||
image=img,
|
||||
mask_image=mask,
|
||||
height=1024, width=1024,
|
||||
guidance_scale=30, # FLUX Fill specific
|
||||
num_inference_steps=50,
|
||||
).images[0]
|
||||
```
|
||||
|
||||
### Outpainting — canvas 확장
|
||||
```python
|
||||
from PIL import Image, ImageOps
|
||||
|
||||
orig = Image.open("portrait.png") # 1024x1024
|
||||
# 매 좌우 512px 확장 → 2048x1024
|
||||
canvas = Image.new("RGB", (2048, 1024), (0, 0, 0))
|
||||
canvas.paste(orig, (512, 0))
|
||||
|
||||
mask = Image.new("L", (2048, 1024), 255) # all white
|
||||
mask.paste(0, (512, 0, 1536, 1024)) # original area = keep
|
||||
|
||||
# 매 feather mask edge 의 seam 회피
|
||||
mask = mask.filter(ImageFilter.GaussianBlur(radius=16))
|
||||
|
||||
result = pipe(
|
||||
prompt="extended cinematic landscape, mountains, golden hour",
|
||||
image=canvas, mask_image=mask,
|
||||
strength=1.0,
|
||||
).images[0]
|
||||
```
|
||||
|
||||
### Adetailer pattern — auto face/hand fix
|
||||
```python
|
||||
# 매 ComfyUI / A1111 — YOLO detect → mask → inpaint
|
||||
from ultralytics import YOLO
|
||||
|
||||
face_det = YOLO("face_yolov8n.pt")
|
||||
boxes = face_det(img)[0].boxes.xyxy
|
||||
|
||||
for box in boxes:
|
||||
x1, y1, x2, y2 = map(int, box)
|
||||
face_mask = Image.new("L", img.size, 0)
|
||||
ImageDraw.Draw(face_mask).rectangle([x1, y1, x2, y2], fill=255)
|
||||
face_mask = face_mask.filter(ImageFilter.GaussianBlur(8))
|
||||
img = pipe(
|
||||
prompt="detailed face, sharp eyes, natural skin",
|
||||
image=img, mask_image=face_mask,
|
||||
strength=0.4, # subtle — preserve identity
|
||||
).images[0]
|
||||
```
|
||||
|
||||
### Differential diffusion — soft mask
|
||||
```python
|
||||
# 매 mask 의 grayscale 의 per-pixel strength 으로 처리
|
||||
soft_mask = Image.open("gradient_mask.png").convert("L")
|
||||
# 매 black=0% strength, white=100% — smooth blend
|
||||
result = pipe(prompt=p, image=img, mask_image=soft_mask, strength=0.8).images[0]
|
||||
```
|
||||
|
||||
### Midjourney Vary Region (UI workflow)
|
||||
```text
|
||||
1. /imagine 로 base image 생성.
|
||||
2. U1 (upscale) 후 "Vary (Region)" 클릭.
|
||||
3. 매 lasso/rectangle 의 region 선택.
|
||||
4. Prompt 의 edit (optional) 후 submit.
|
||||
5. 매 4 variant 의 seed 만 region 의 regenerate.
|
||||
```
|
||||
|
||||
### Mask preprocessing — clean edge
|
||||
```python
|
||||
import numpy as np
|
||||
import cv2
|
||||
|
||||
mask_np = np.array(mask)
|
||||
# 매 dilate (확장) 의 seam 의 hide
|
||||
mask_np = cv2.dilate(mask_np, np.ones((5,5), np.uint8), iterations=2)
|
||||
# 매 feather
|
||||
mask_np = cv2.GaussianBlur(mask_np, (21, 21), 0)
|
||||
mask = Image.fromarray(mask_np)
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Object 교체 (vase) | hard mask + strength=0.95 + SDXL Inpaint |
|
||||
| Background extension | feathered mask + outpaint + strength=1.0 |
|
||||
| Face detail fix | YOLO-detect mask + strength=0.3-0.5 |
|
||||
| Subtle texture tweak | strength=0.2 + soft mask |
|
||||
| Photoreal fill | FLUX.1 Fill > SDXL Inpaint |
|
||||
| Stylized iteration | MJ Vary Region |
|
||||
|
||||
**기본값**: photoreal → FLUX.1 Fill, stylized → MJ Vary Region, batch automation → SDXL Inpaint + adetailer.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[AI 이미지 생성 및 편집 워크플로우 (AI Image Generation & Editing Workflow)]]
|
||||
- 응용: [[상업용 제품 사진 및 브랜드 로고 디자인]] · [[부정 프롬프트와 가중치를 활용한 시각적 아티팩트(Artifact) 디버깅 및 제어]]
|
||||
- Adjacent: [[Adetailer]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: object replacement, background extension, face/hand defect fix, brand asset iteration.
|
||||
**언제 X**: identity preservation 의 strict requirement — IP-Adapter / instantID 의 사용 의 추천.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Hard mask 의 seam visible**: feather + dilate 의 누락.
|
||||
- **Strength=1.0 의 face**: identity 의 파괴 — 0.3-0.5 의 사용.
|
||||
- **Full-image prompt 만**: masked region 의 context 의 누락 — masked-specific term 의 추가.
|
||||
- **Square mask 의 organic object**: SAM 의 사용 의 정확 mask.
|
||||
- **Outpaint 의 strength<1.0**: 매 black 영역 의 noise 의 incomplete fill.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Diffusers SDXL Inpaint docs, FLUX.1 Fill model card, Midjourney v6 docs).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — inpaint/outpaint/vary 3-mode + FLUX Fill |
|
||||
Reference in New Issue
Block a user