[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,73 +2,196 @@
|
||||
id: wiki-2026-0508-미드저니-및-스테이블-디퓨전의-부분-편집-기법
|
||||
title: 미드저니 및 스테이블 디퓨전의 부분 편집 기법
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: []
|
||||
aliases: [Inpainting, Outpainting, Vary Region, Partial Edit]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.92
|
||||
tags: [uncategorized]
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [diffusion, inpainting, midjourney, sdxl, flux]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-08
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: python
|
||||
framework: diffusers
|
||||
---
|
||||
|
||||
# [[미드저니 및 스테이블 디퓨전의 부분 편집 기법|미드저니 및 스테이블 디퓨전의 부분 편집 기법]]
|
||||
# 미드저니 및 스테이블 디퓨전의 부분 편집 기법
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
미드저니와 스테이블 디퓨전의 부분 편집 기법(인페인팅, Inpainting)은 생성된 이미지의 전체 맥락을 유지하면서 특정 영역만을 선택하여 수정, 추가 또는 제거하는 기능입니다 [1, 2]. 미드저니에서는 이를 'Vary (Region)' 기능으로 제공하며, 리믹스(Remix) 모드와 결합해 선택 영역에 대한 새로운 프롬프트를 적용함으로써 정교한 이미지 합성을 수행할 수 있습니다 [3, 4]. 스테이블 디퓨전에서도 인페인팅은 배경 교체와 같은 특정 영역의 세부 편집 및 정교화(Refinement) 도구로 활발히 사용됩니다 [1].
|
||||
## 매 한 줄
|
||||
> **"매 부분 편집 매 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.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
- **미드저니의 Vary (Region) 기능과 작동 방식**
|
||||
- 업스케일링된 이미지에서 사각형(Rectangle) 또는 올가미(Freehand) 도구를 사용해 변경할 영역을 지정합니다 [5, 6].
|
||||
- 리믹스(Remix) 모드를 활성화한 상태에서, 선택한 영역에 도입하거나 변경하고자 하는 요소에 집중하여 프롬프트를 수정합니다 [3, 4, 7]. 이를 통해 인물의 모자를 왕관으로 바꾸거나 배경에 새로운 객체를 추가하는 작업 등을 기존 이미지의 맥락을 완벽히 유지하며 수행할 수 있습니다 [4, 8].
|
||||
## 매 핵심
|
||||
|
||||
- **효과적인 부분 편집을 위한 프롬프트 및 선택 영역 노하우**
|
||||
- **선택 영역의 크기 확보**: 선택 영역의 크기는 결과물에 큰 영향을 미칩니다. 영역을 넓게 잡으면 AI가 기존 이미지와의 시각적 맥락(Context)을 파악하고 자연스럽게 합성할 수 있는 여유를 주지만, 너무 좁게 잡으면 주변부와의 연결성을 이해하기 어려워집니다 [4, 6, 9]. 따라서 대상 주변의 여백을 충분히 포함하여 선택하는 것이 기술적 노하우입니다 [4].
|
||||
- **간결하고 직관적인 프롬프트 작성**: "초원 길을 아름다운 시냇물로 바꿔주세요"와 같은 문장형 지시보다는 "초원의 시냇물(meadow stream)"처럼 변경할 대상 자체를 직접적으로 입력하는 것이 훨씬 효과적입니다 [9].
|
||||
- **단계적 수정**: 여러 부분을 수정해야 할 경우, 한 번에 한 영역씩 집중하여 단계적으로 작업(Small steps)하는 것이 유리합니다 [10].
|
||||
### 매 3가지 mode
|
||||
- **Inpainting**: existing region 의 mask 의 그리고 prompt 로 replace.
|
||||
- **Outpainting**: image 의 canvas 의 확장 의 새 region 의 채움.
|
||||
- **Vary Region (MJ)**: subset 의 selective regeneration — context-aware.
|
||||
|
||||
- **스테이블 디퓨전에서의 인페인팅(Inpainting)**
|
||||
- 텍스트-이미지 생성 모델의 일반적인 사후 편집 과정 중 하나로, 이미지의 특정 영역을 편집하거나 배경을 전환하는 등의 목적에 널리 사용됩니다 [1].
|
||||
- (주의: 소스에 미드저니의 부분 편집(Vary Region)에 대한 방법론은 상세히 서술되어 있으나, 스테이블 디퓨전 고유의 인페인팅 프롬프트 작성 기법에 대한 구체적인 관련 정보가 부족합니다.)
|
||||
### 매 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.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- **Related Topics:** [[인페인팅 (Inpainting)|인페인팅(Inpainting)]], [[리믹스 모드 (Remix Mode)|리믹스 모드(Remix Mode)]], 프롬프트 정교화(Prompt Refinement)
|
||||
- **Projects/Contexts:** 생성형 AI 사후 편집 및 이미지 정교화 워크플로우
|
||||
- **Contradictions/Notes:** 소스 내에 미드저니의 부분 편집(Vary Region)에 대한 기능적 설명과 프롬프트 지침은 구체적으로 명시되어 있지만, 스테이블 디퓨전의 인페인팅 적용 방법에 대한 상세한 정보는 소스에 관련 정보가 부족합니다 [1, 2, 4, 9].
|
||||
### 매 응용
|
||||
1. Object 추가/제거 — 매 background 의 보존 의 selective replace.
|
||||
2. Outpaint 의 wide aspect — 16:9 → 21:9 cinematic.
|
||||
3. Face/hand fix — adetailer 의 auto-detect mask + inpaint pass.
|
||||
|
||||
---
|
||||
*Last updated: 2026-04-30*
|
||||
## 💻 패턴
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
### SDXL Inpaint pipeline
|
||||
```python
|
||||
from diffusers import StableDiffusionXLInpaintPipeline
|
||||
from PIL import Image
|
||||
import torch
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
pipe = StableDiffusionXLInpaintPipeline.from_pretrained(
|
||||
"diffusers/stable-diffusion-xl-1.0-inpainting-0.1",
|
||||
torch_dtype=torch.float16,
|
||||
).to("cuda")
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
img = Image.open("photo.png").convert("RGB")
|
||||
mask = Image.open("mask.png").convert("L") # white = replace, black = keep
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
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]
|
||||
```
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
### FLUX.1 Fill (2024-2026 SOTA)
|
||||
```python
|
||||
from diffusers import FluxFillPipeline
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
pipe = FluxFillPipeline.from_pretrained(
|
||||
"black-forest-labs/FLUX.1-Fill-dev",
|
||||
torch_dtype=torch.bfloat16,
|
||||
).to("cuda")
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
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]
|
||||
```
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
### 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))
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
mask = Image.new("L", (2048, 1024), 255) # all white
|
||||
mask.paste(0, (512, 0, 1536, 1024)) # original area = keep
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
# 매 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)]]
|
||||
- 변형: [[ControlNet Inpaint]] · [[IP-Adapter Inpaint]]
|
||||
- 응용: [[상업용 제품 사진 및 브랜드 로고 디자인]] · [[부정 프롬프트와 가중치를 활용한 시각적 아티팩트(Artifact) 디버깅 및 제어]]
|
||||
- Adjacent: [[Adetailer]] · [[Differential Diffusion]] · [[SAM (Segment Anything)]]
|
||||
|
||||
## 🤖 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