Files
2nd/10_Wiki/Topics/AI_and_ML/Vary Region (인페인팅).md
T
Antigravity Agent f8b21af4be Wiki cleanup: error-doc removal, dedup merge, link normalization
10_Wiki/Topics 대규모 정리:
- 오류 캡처/미완성 stub 문서 227개 제거
- 교차폴더 중복 43클러스터 병합 (63파일 → redirect)
- 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건
- 카테고리 MOC 6개 신규 생성
- Graph 섹션 미해결 related-keyword 링크 10,058건 제거

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 23:52:15 +09:00

6.7 KiB

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-vary-region-인페인팅 Vary Region (인페인팅) 10_Wiki/Topics verified self
Inpainting
Midjourney Vary Region
Region-Based Editing
none A 0.9 applied
image-generation
inpainting
midjourney
editing
diffusion
2026-05-10 pending
language framework
text Midjourney/FLUX-Fill/SDXL-Inpainting

Vary Region (인페인팅)

매 한 줄

"매 Vary Region 의 핵심 = 'mask 의 selective regeneration with prompt 의 re-injection'.". 매 2023 Midjourney 의 introduction 의 since 매 industry standard 의 region-aware editing 의 became. 2026 era 매 FLUX.1 Fill / SDXL Inpainting / Adobe Firefly Generative Fill 의 mainstream — 매 entire image 의 regenerate 의 X 의 specific area 만 의 modify.

매 핵심

매 동작 원리

  • Mask: 매 binary image (white = edit, black = preserve) 의 user-drawn or auto-segmented.
  • Latent blending: 매 unmasked region 의 original latent 의 preserve, masked region 만 의 noise → denoise.
  • Prompt re-injection: 매 new prompt 의 masked area 의 conditioning 의 only.
  • Boundary blending: 매 mask edge 의 soft blur 의 seamless transition.

매 Use cases

  • Object removal: unwanted person / watermark / logo 의 remove.
  • Object addition: empty desk 의 coffee cup 의 add.
  • Object replacement: red car → blue car.
  • Detail enhancement: face / hand 의 specific 의 refinement.
  • Outpainting: 매 canvas 의 expand 의 logical extension.

매 Variants

  1. Vary Region (Subtle): 매 minor change — color / texture.
  2. Vary Region (Strong): 매 major regeneration — different object.
  3. Remix mode: 매 prompt 의 swap 의 enable.

💻 패턴

Pattern 1: Midjourney 의 Vary Region workflow

1. /imagine prompt: cozy living room, modern minimalist
2. Upscale → click "Vary (Region)"
3. Draw mask over old TV
4. Edit prompt: "large bookshelf with plants"
5. Submit → MJ regenerates only masked area

Pattern 2: SDXL inpainting (diffusers)

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")

init_image = Image.open("room.png").convert("RGB")
mask_image = Image.open("mask.png").convert("RGB")  # white = inpaint

result = pipe(
    prompt="large oak bookshelf filled with leather books and potted plants",
    image=init_image,
    mask_image=mask_image,
    strength=0.95,
    guidance_scale=8.0,
    num_inference_steps=40,
).images[0]

result.save("inpainted.png")

Pattern 3: FLUX.1 Fill (2026 SOTA)

import replicate

output = replicate.run(
    "black-forest-labs/flux-fill-pro",
    input={
        "image": open("room.png", "rb"),
        "mask": open("mask.png", "rb"),
        "prompt": "vintage typewriter on wooden desk",
        "guidance_scale": 30,  # FLUX uses higher guidance
        "num_inference_steps": 50,
    },
)

Pattern 4: Auto-mask via SAM 2 (Segment Anything)

from segment_anything_2 import SAM2ImagePredictor
import numpy as np

predictor = SAM2ImagePredictor.from_pretrained("facebook/sam2-hiera-large")
predictor.set_image(image)

# Click point on object to remove
point_coords = np.array([[450, 300]])
point_labels = np.array([1])

masks, scores, _ = predictor.predict(
    point_coords=point_coords,
    point_labels=point_labels,
    multimask_output=True,
)
best_mask = masks[scores.argmax()]

Pattern 5: Outpainting (canvas expansion)

from PIL import Image

# Expand canvas to right
original = Image.open("portrait.png")  # 512x512
expanded = Image.new("RGB", (1024, 512), (0, 0, 0))
expanded.paste(original, (0, 0))

# Mask: black on left half (preserve), white on right half (generate)
mask = Image.new("L", (1024, 512), 0)
for x in range(512, 1024):
    for y in range(512):
        mask.putpixel((x, y), 255)

result = pipe(
    prompt="continuation of mountain landscape, same lighting and style",
    image=expanded,
    mask_image=mask,
    strength=1.0,
).images[0]

Pattern 6: ControlNet Inpaint (preserve structure)

from diffusers import StableDiffusionXLControlNetInpaintPipeline, ControlNetModel

controlnet = ControlNetModel.from_pretrained("destitech/controlnet-inpaint-dreamer-sdxl")
pipe = StableDiffusionXLControlNetInpaintPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    controlnet=controlnet,
)

# Preserves edges / depth while regenerating
result = pipe(
    prompt="red sports car, same angle and lighting",
    image=original,
    mask_image=mask,
    control_image=canny_edge_map,
).images[0]

Pattern 7: Adobe Firefly Generative Fill (Photoshop API)

const response = await fetch('https://firefly-api.adobe.io/v3/images/generative-fill', {
  method: 'POST',
  headers: { Authorization: `Bearer ${token}` },
  body: JSON.stringify({
    image: { source: { url: imageUrl } },
    mask:  { source: { url: maskUrl } },
    prompt: 'a vase of fresh tulips',
  }),
});

매 결정 기준

상황 Approach
Casual / no-code Midjourney Vary Region
Photoshop integrated Adobe Firefly Generative Fill
API / batch FLUX.1 Fill Pro (Replicate)
Local / private SDXL Inpainting + diffusers
Auto-mask SAM 2 + inpainting pipe
Preserve structure ControlNet Inpaint variant

기본값: FLUX.1 Fill Pro (quality) 또는 SDXL Inpainting (local/free).

🔗 Graph

🤖 LLM 활용

언제: mask region 의 prompt 의 generation / what-to-remove decision / multi-region edit planning. 언제 X: 매 mask itself 의 drawing — 매 visual / spatial task 의 LLM 의 weak.

안티패턴

  • Mask too tight: 매 boundary artifact — 매 8-16px feather 의 add.
  • Strength=1.0 with same prompt: 매 unnecessary regeneration. strength=0.7-0.95 의 prefer.
  • Ignoring lighting consistency: 매 inpainted region 의 lighting 의 mismatch — 매 prompt 의 explicit "same lighting" 의 add.
  • No reference to surroundings: prompt 의 isolated description — 매 context 의 mention ("matching the wooden desk").

🧪 검증 / 중복

  • Verified: Midjourney docs (2026), Black Forest Labs FLUX Fill paper, diffusers documentation.
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — full inpainting / Vary Region guide