Diffusers documentation
텍스트 기반 깊이-이미지 생성
시작하기
추론
확산 파이프라인 사용
어댑터 및 개인화
최적화 및 확장
모듈형 Diffusers
학습 및 파인튜닝
리소스
기여하기
API
You are viewing main version, which requires installation from source. If you'd like
regular pip install, checkout the latest stable version (v0.42.1).
텍스트 기반 깊이-이미지 생성
StableDiffusionDepth2ImgPipeline를 사용하면 텍스트 프롬프트와 초기 이미지를 전달하여 새로운 이미지 생성을 조건화할 수 있습니다. 또한 이미지 구조를 유지하기 위해 depth_map을 전달할 수도 있습니다. depth_map이 제공되지 않으면 파이프라인은 통합된 depth-estimation model을 통해 깊이를 자동으로 예측합니다.
StableDiffusionDepth2ImgPipeline의 인스턴스를 생성하는 것으로 시작합니다:
import torch
from diffusers import StableDiffusionDepth2ImgPipeline
from diffusers.utils import load_image, make_image_grid
pipeline = StableDiffusionDepth2ImgPipeline.from_pretrained(
"stabilityai/stable-diffusion-2-depth",
dtype=torch.float16,
use_safetensors=True,
).to("cuda") # or "mps", "xpu", "cpu"이제 프롬프트를 pipeline에 전달합니다. 특정 단어가 이미지 생성 방식을 유도하는 것을 방지하려면 negative_prompt도 전달할 수 있습니다:
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
init_image = load_image(url)
prompt = "two tigers"
negative_prompt = "bad, deformed, ugly, bad anatomy"
image = pipeline(prompt=prompt, image=init_image, negative_prompt=negative_prompt, strength=0.7).images[0]
make_image_grid([init_image, image], rows=1, cols=2)| 입력 | 출력 |
|---|---|
![]() | ![]() |

