Buckets:
Depth-to-image
Stable Diffusion ๋ชจ๋ธ์ MiDaS๋ฅผ ์ฌ์ฉํ์ฌ ์ด๋ฏธ์ง ๊ธฐ๋ฐ์ ๊น์ด ์ถ์ ๋ ์ํํ ์ ์์ต๋๋ค. ์ด๋ฅผ ํตํด ํ
์คํธ ํ๋กฌํํธ์ ์ด๊ธฐ ์ด๋ฏธ์ง๋ฅผ ์ ๋ฌํ์ฌ ์๋ก์ด ์ด๋ฏธ์ง ์์ฑ์ ์กฐ๊ฑดํํ๊ณ , ์ด๋ฏธ์ง ๊ตฌ์กฐ๋ฅผ ๋ณด์กดํ๊ธฐ ์ํด depth_map์ ์ ๋ฌํ ์ ์์ต๋๋ค.
์ค์ผ์ค๋ฌ์ ์๋์ ํ์ง ์ฌ์ด์ ํธ๋ ์ด๋์คํ๋ฅผ ํ์ํ๋ ๋ฐฉ๋ฒ๊ณผ ํ์ดํ๋ผ์ธ ๊ตฌ์ฑ ์์๋ฅผ ํจ์จ์ ์ผ๋ก ์ฌ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ฐฐ์ฐ๋ ค๋ฉด Stable Diffusion Tips ์น์ ์ ๊ผญ ํ์ธํ์ธ์!
ํน์ ์์ ์ ๊ณต์ ์ฒดํฌํฌ์ธํธ ์ค ํ๋๋ฅผ ์ฌ์ฉํ๋ ค๋ ๊ฒฝ์ฐ, CompVis ๋ฐ Stability AI Hub ์กฐ์ง์ ํ์ํด ๋ณด์ธ์!
StableDiffusionDepth2ImgPipeline[[diffusers.StableDiffusionDepth2ImgPipeline]]
diffusers.StableDiffusionDepth2ImgPipeline[[diffusers.StableDiffusionDepth2ImgPipeline]]
diffusers.StableDiffusionDepth2ImgPipeline(vae: AutoencoderKL, text_encoder: CLIPTextModel, tokenizer: CLIPTokenizer, unet: UNet2DConditionModel, scheduler: KarrasDiffusionSchedulers, depth_estimator: DPTForDepthEstimation, feature_extractor: DPTImageProcessorPil)
๋งค๊ฐ๋ณ์:
vae (AutoencoderKL) : ์ด๋ฏธ์ง๋ฅผ ์ ์ฌ ํํ์ผ๋ก ์ธ์ฝ๋ฉํ๊ณ ์ ์ฌ ํํ์์ ์ด๋ฏธ์ง๋ก ๋์ฝ๋ฉํ๋ Variational Auto-Encoder (VAE) ๋ชจ๋ธ์ ๋๋ค.
text_encoder (CLIPTextModel) : ๊ณ ์ ๋ ํ ์คํธ ์ธ์ฝ๋ (clip-vit-large-patch14).
tokenizer (CLIPTokenizer) : ํ
์คํธ๋ฅผ ํ ํฐํํ๊ธฐ ์ํ CLIPTokenizer์
๋๋ค.
unet (UNet2DConditionModel) : ์ธ์ฝ๋ฉ๋ ์ด๋ฏธ์ง latents์ ๋
ธ์ด์ฆ๋ฅผ ์ ๊ฑฐํ๊ธฐ ์ํ UNet2DConditionModel.
scheduler (SchedulerMixin) : unet์ ํจ๊ป ์ฌ์ฉ๋์ด ์ธ์ฝ๋ฉ๋ ์ด๋ฏธ์ง latents์ ๋
ธ์ด์ฆ๋ฅผ ์ ๊ฑฐํ๋ ์ค์ผ์ค๋ฌ์
๋๋ค. DDIMScheduler, LMSDiscreteScheduler, ๋๋ PNDMScheduler ์ค ํ๋์ผ ์ ์์ต๋๋ค.
Stable Diffusion์ ์ฌ์ฉํ ํ ์คํธ ๊ธฐ๋ฐ์ ๊น์ด ๊ธฐ๋ฐ ์ด๋ฏธ์ง-์ด๋ฏธ์ง ์์ฑ์ ์ํ Pipeline์ ๋๋ค.
์ด ๋ชจ๋ธ์ DiffusionPipeline์์ ์์๋ฉ๋๋ค. ๋ชจ๋ ํ์ดํ๋ผ์ธ์ ๋ํด ๊ตฌํ๋ ์ผ๋ฐ์ ๋ฉ์๋(๋ค์ด๋ก๋, ์ ์ฅ, ํน์ ๋๋ฐ์ด์ค์์ ์คํ ๋ฑ)์ ๋ํด์๋ ์์ ํด๋์ค ๋ฌธ์๋ฅผ ํ์ธํ์ธ์.
ํ์ดํ๋ผ์ธ์ ๋ค์ ๋ก๋ฉ ๋ฉ์๋๋ ์์ํฉ๋๋ค:
- ํ ์คํธ ์ธ๋ฒ์ ์๋ฒ ๋ฉ์ ๋ก๋ํ๋ load_textual_inversion()
- LoRA ๊ฐ์ค์น๋ฅผ ๋ก๋ํ๋ load_lora_weights()
- LoRA ๊ฐ์ค์น๋ฅผ ์ ์ฅํ๋ save_lora_weights()
ํธ์ถ[[diffusers.StableDiffusionDepth2ImgPipeline.call]]
__call__(prompt: str | list[str] = None, image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]] = None, depth_map: typing.Optional[torch.Tensor] = None, strength: float = 0.8, num_inference_steps: int | None = 50, guidance_scale: float | None = 7.5, negative_prompt: str | list[str] | None = None, num_images_per_prompt: int | None = 1, eta: float | None = 0.0, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, output_type: str | None = 'pil', return_dict: bool = True, cross_attention_kwargs: dict[str, typing.Any] | None = None, clip_skip: int | None = None, callback_on_step_end: typing.Optional[typing.Callable[[int, int], NoneType]] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], **kwargs)
๋งค๊ฐ๋ณ์:
prompt (str ๋๋ list[str], ์ ํ ์ฌํญ) : ์ด๋ฏธ์ง ์์ฑ์ ์๋ดํ ํ๋กฌํํธ์
๋๋ค. ์ ์๋์ง ์์ ๊ฒฝ์ฐ prompt_embeds๋ฅผ ์ ๋ฌํด์ผ ํฉ๋๋ค.
image (torch.Tensor, PIL.Image.Image, np.ndarray, list[torch.Tensor], list[PIL.Image.Image], ๋๋ list[np.ndarray]) : ์์์ ์ผ๋ก ์ฌ์ฉํ ์ด๋ฏธ์ง ๋ฐฐ์น์ Image ๋๋ ํ
์๋ฅผ ๋ํ๋
๋๋ค. depth_map์ด None์ด ์๋ ๊ฒฝ์ฐ์๋ง ์ด๋ฏธ์ง ์ ์ฌ๋ฅผ image๋ก ๋ฐ์ ์ ์์ต๋๋ค.
depth_map (torch.Tensor, ์ ํ ์ฌํญ) : ์ด๋ฏธ์ง ์์ฑ ๊ณผ์ ์ ์ถ๊ฐ ์กฐ๊ฑด์ผ๋ก ์ฌ์ฉํ ๊น์ด ์์ธก ๊ฐ์
๋๋ค. ์ ์๋์ง ์์ ๊ฒฝ์ฐ self.depth_estimator๋ก ๊น์ด๋ฅผ ์๋์ผ๋ก ์์ธกํฉ๋๋ค.
strength (float, ์ ํ ์ฌํญ, ๊ธฐ๋ณธ๊ฐ 0.8) : ์ฐธ์กฐ image๋ฅผ ๋ณํํ ์ ๋๋ฅผ ๋ํ๋
๋๋ค. 0๊ณผ 1 ์ฌ์ด์ฌ์ผ ํฉ๋๋ค. image๋ ์์์ ์ผ๋ก ์ฌ์ฉ๋๋ฉฐ, strength ๊ฐ์ด ๋์์๋ก ๋ ๋ง์ ๋
ธ์ด์ฆ๊ฐ ์ถ๊ฐ๋ฉ๋๋ค. ๋๋
ธ์ด์ง ๋จ๊ณ์ ์๋ ์ด๊ธฐ์ ์ถ๊ฐ๋ ๋
ธ์ด์ฆ์ ์์ ๋ฐ๋ผ ๊ฒฐ์ ๋ฉ๋๋ค. strength๊ฐ 1์ด๋ฉด ์ถ๊ฐ๋๋ ๋
ธ์ด์ฆ๊ฐ ์ต๋๊ฐ ๋๋ฉฐ, num_inference_steps์ ์ง์ ๋ ์ ์ฒด ๋ฐ๋ณต ํ์๋งํผ ๋๋
ธ์ด์ง ํ๋ก์ธ์ค๊ฐ ์คํ๋ฉ๋๋ค. 1์ด๋ผ๋ ๊ฐ์ ์ฌ์ค์ image๋ฅผ ๋ฌด์ํ๋ ๊ฒ๊ณผ ๊ฐ์ต๋๋ค.
num_inference_steps (int, ์ ํ ์ฌํญ, ๊ธฐ๋ณธ๊ฐ 50) : ๋๋
ธ์ด์ง ๋จ๊ณ ์์
๋๋ค. ๋๋
ธ์ด์ง ๋จ๊ณ๊ฐ ๋ง์์๋ก ์ผ๋ฐ์ ์ผ๋ก ์ถ๋ก ์๋๊ฐ ๋๋ ค์ง๋ ๋์ ๋ ๋์ ํ์ง์ ์ด๋ฏธ์ง๋ฅผ ์์ฑํฉ๋๋ค. ์ด ๋งค๊ฐ๋ณ์๋ strength์ ์ํด ์กฐ์ ๋ฉ๋๋ค.
guidance_scale (float, ์ ํ ์ฌํญ, ๊ธฐ๋ณธ๊ฐ 7.5) : guidance scale ๊ฐ์ด ๋์์๋ก ๋ชจ๋ธ์ ์ด๋ฏธ์ง ํ์ง์ด ๋ฎ์์ง๋ ๋์ ํ
์คํธ prompt์ ๋ฐ์ ํ๊ฒ ์ฐ๊ฒฐ๋ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋๋ก ์ ๋๋ฉ๋๋ค. guidance_scale > 1์ผ ๋ guidance scale์ด ํ์ฑํ๋ฉ๋๋ค.
negative_prompt (str ๋๋ list[str], ์ ํ) : ์ด๋ฏธ์ง ์์ฑ์์ ํฌํจํ์ง ์์ ๋ด์ฉ์ ์๋ดํ๋ ํ๋กฌํํธ์
๋๋ค. ์ ์๋์ง ์์ ๊ฒฝ์ฐ ๋์ negative_prompt_embeds๋ฅผ ์ ๋ฌํด์ผ ํฉ๋๋ค. ๊ฐ์ด๋์ค๋ฅผ ์ฌ์ฉํ์ง ์์ ๋(guidance_scale < 1)์๋ ๋ฌด์๋ฉ๋๋ค.
num_images_per_prompt (int, ์ ํ ์ฌํญ, ๊ธฐ๋ณธ๊ฐ 1) : ํ๋กฌํํธ๋น ์์ฑํ ์ด๋ฏธ์ง์ ์.
eta (float, ์ ํ ์ฌํญ, ๊ธฐ๋ณธ๊ฐ 0.0) : DDIM ๋
ผ๋ฌธ์์ ์ ์ํ ํ๋ผ๋ฏธํฐ eta (ฮท)์ ํด๋นํฉ๋๋ค. DDIMScheduler์๋ง ์ ์ฉ๋๋ฉฐ, ๋ค๋ฅธ ์ค์ผ์ค๋ฌ์์๋ ๋ฌด์๋ฉ๋๋ค.
generator (torch.Generator ๋๋ list[torch.Generator], ์ ํ ์ฌํญ) : ์์ฑ์ ๊ฒฐ์ ์ ์ผ๋ก ๋ง๋ค๊ธฐ ์ํ torch.Generator์
๋๋ค.
prompt_embeds (torch.Tensor, ์ ํ ์ฌํญ) : ๋ฏธ๋ฆฌ ์์ฑ๋ ํ
์คํธ ์๋ฒ ๋ฉ์
๋๋ค. ํ
์คํธ ์
๋ ฅ(ํ๋กฌํํธ ๊ฐ์ค์น)์ ์ฝ๊ฒ ์กฐ์ ํ๋ ๋ฐ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ ๊ณต๋์ง ์์ผ๋ฉด prompt ์
๋ ฅ ์ธ์์์ ํ
์คํธ ์๋ฒ ๋ฉ์ด ์์ฑ๋ฉ๋๋ค.
negative_prompt_embeds (torch.Tensor, ์ ํ ์ฌํญ) : ๋ฏธ๋ฆฌ ์์ฑ๋ ๋ถ์ ํ
์คํธ ์๋ฒ ๋ฉ์
๋๋ค. ํ
์คํธ ์
๋ ฅ(ํ๋กฌํํธ ๊ฐ์ค์น)์ ์ฝ๊ฒ ์กฐ์ ํ๋ ๋ฐ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ ๊ณต๋์ง ์์ผ๋ฉด negative_prompt ์
๋ ฅ ์ธ์์์ negative_prompt_embeds๊ฐ ์์ฑ๋ฉ๋๋ค.
output_type (str, ์ ํ ์ฌํญ, ๊ธฐ๋ณธ๊ฐ "pil") : ์์ฑ๋ ์ด๋ฏธ์ง์ ์ถ๋ ฅ ํ์์
๋๋ค. PIL.Image ๋๋ np.array ์ค ํ๋๋ฅผ ์ ํํฉ๋๋ค.
return_dict (bool, ์ ํ ์ฌํญ, ๊ธฐ๋ณธ๊ฐ True) : ์ผ๋ฐ ํํ ๋์ StableDiffusionPipelineOutput์ ๋ฐํํ ์ง ์ฌ๋ถ.
cross_attention_kwargs (dict, ์ ํ ์ฌํญ) : ์ง์ ๋ ๊ฒฝ์ฐ self.processor์์ ์ ์๋ AttentionProcessor๋ก ์ ๋ฌ๋๋ kwargs ์ฌ์ ์
๋๋ค.
clip_skip (int, ์ ํ ์ฌํญ) : ํ๋กฌํํธ ์๋ฒ ๋ฉ์ ๊ณ์ฐํ ๋ CLIP์์ ๊ฑด๋๋ธ ๋ ์ด์ด ์. ๊ฐ์ด 1์ด๋ฉด ์ต์ข
๋ ์ด์ด ๋ฐ๋ก ์ด์ ๋ ์ด์ด์ ์ถ๋ ฅ์ ํ๋กฌํํธ ์๋ฒ ๋ฉ ๊ณ์ฐ์ ์ฌ์ฉํฉ๋๋ค.
callback_on_step_end (Callable, ์ ํ ์ฌํญ) : ์ถ๋ก ์ค ๊ฐ ๋๋
ธ์ด์ง ๋จ๊ณ์ ๋์์ ํธ์ถ๋๋ ํจ์์
๋๋ค. ์ด ํจ์๋ ๋ค์ ์ธ์๋ฅผ ๋ฐ์ ํธ์ถ๋ฉ๋๋ค: callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict). callback_kwargs์๋ callback_on_step_end_tensor_inputs๋ก ์ง์ ๋ ๋ชจ๋ ํ
์ ๋ชฉ๋ก์ด ํฌํจ๋ฉ๋๋ค.
callback_on_step_end_tensor_inputs (list, ์ ํ ์ฌํญ) : callback_on_step_end ํจ์์ ํ
์ ์
๋ ฅ ๋ชฉ๋ก์
๋๋ค. ๋ชฉ๋ก์ ์ง์ ๋ ํ
์๋ callback_kwargs ์ธ์๋ก ์ ๋ฌ๋ฉ๋๋ค. ํ์ดํ๋ผ์ธ ํด๋์ค์ ._callback_tensor_inputs ์์ฑ์ ๋์ด๋ ๋ณ์๋ง ํฌํจํ ์ ์์ต๋๋ค.
๋ฐํ๊ฐ: StableDiffusionPipelineOutput ๋๋ tuple
return_dict๊ฐ True์ธ ๊ฒฝ์ฐ StableDiffusionPipelineOutput๊ฐ ๋ฐํ๋๊ณ , ๊ทธ๋ ์ง ์์ผ๋ฉด ์ฒซ ๋ฒ์งธ ์์๊ฐ ์์ฑ๋ ์ด๋ฏธ์ง์ ๋ชฉ๋ก์ธ tuple์ด ๋ฐํ๋ฉ๋๋ค.
์์ฑ์ ์ํ pipeline์ ํธ์ถ ํจ์.
์:
>>> import torch
>>> import requests
>>> from PIL import Image
>>> from diffusers import StableDiffusionDepth2ImgPipeline
>>> pipe = StableDiffusionDepth2ImgPipeline.from_pretrained(
... "stabilityai/stable-diffusion-2-depth",
... torch_dtype=torch.float16,
... )
>>> pipe.to("cuda")
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> init_image = Image.open(requests.get(url, stream=True).raw)
>>> prompt = "two tigers"
>>> n_prompt = "bad, deformed, ugly, bad anotomy"
>>> image = pipe(prompt=prompt, image=init_image, negative_prompt=n_prompt, strength=0.7).images[0]
enable_attention_slicing[[diffusers.StableDiffusionDepth2ImgPipeline.enable_attention_slicing]]
enable_attention_slicing(slice_size: str | int = 'auto')
๋งค๊ฐ๋ณ์:
slice_size (str ๋๋ int, ์ ํ ์ฌํญ, ๊ธฐ๋ณธ๊ฐ "auto") : "auto"์ธ ๊ฒฝ์ฐ attention heads์ ์ ๋ฌ๋๋ ์
๋ ฅ์ ์ ๋ฐ์ผ๋ก ์ค์ฌ attention์ ๋ ๋จ๊ณ๋ก ๊ณ์ฐํฉ๋๋ค. "max"์ธ ๊ฒฝ์ฐ ํ ๋ฒ์ ํ๋์ ์ฌ๋ผ์ด์ค๋ง ์คํํ์ฌ ์ต๋์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ ์ฝํฉ๋๋ค. ์ซ์๊ฐ ์ ๊ณต๋๋ฉด attention_head_dim // slice_size๋งํผ์ ์ฌ๋ผ์ด์ค๋ฅผ ์ฌ์ฉํฉ๋๋ค. ์ด ๊ฒฝ์ฐ attention_head_dim์ slice_size์ ๋ฐฐ์์ฌ์ผ ํฉ๋๋ค.
์ฌ๋ผ์ด์ค๋ ์ดํ ์ ๊ณ์ฐ์ ํ์ฑํํฉ๋๋ค. ์ด ์ต์ ์ด ํ์ฑํ๋๋ฉด ์ดํ ์ ๋ชจ๋์ ์ ๋ ฅ ํ ์๋ฅผ ์ฌ๋ผ์ด์ค๋ก ๋ถํ ํ์ฌ ์ฌ๋ฌ ๋จ๊ณ์ ๊ฑธ์ณ ์ดํ ์ ์ ๊ณ์ฐํฉ๋๋ค. ์ดํ ์ ํค๋ ํ๋๊ฐ ๋๋ ๊ฒฝ์ฐ, ๊ฐ ํค๋๋ฅผ ์์ฐจ์ ์ผ๋ก ๊ณ์ฐํฉ๋๋ค. ์ด๋ ์๋๊ฐ ์ฝ๊ฐ ๊ฐ์ํ๋ ๋์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ ์ฝํ๋ ๋ฐ ์ ์ฉํฉ๋๋ค.
> โ ๏ธ ์ด๋ฏธ
scaled_dot_product_attention(SDPA)๋ฅผ ์ฌ์ฉ ์ค์ด๋ผ๋ฉด attention slicing์ ํ์ฑํํ์ง ๋ง์ธ์ from PyTorch > 2.0 or xFormers. ์ด๋ฌํ attention ๊ณ์ฐ์ ์ด๋ฏธ ๋ฉ๋ชจ๋ฆฌ ํจ์จ์ฑ์ด ๋งค์ฐ ๋์ ์ด ๊ธฐ๋ฅ์ ํ์ฑํํ ํ์๊ฐ ์์ต๋๋ค. SDPA ๋๋ xFormers์ ํจ๊ป attention slicing์ ํ์ฑํํ๋ฉด ์ฌ๊ฐํ ์ฑ๋ฅ ์ ํ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค!
์:
>>> import torch
>>> from diffusers import StableDiffusionPipeline
>>> pipe = StableDiffusionPipeline.from_pretrained(
... "stable-diffusion-v1-5/stable-diffusion-v1-5",
... dtype=torch.float16,
... use_safetensors=True,
... )
>>> prompt = "a photo of an astronaut riding a horse on mars"
>>> pipe.enable_attention_slicing()
>>> image = pipe(prompt).images[0]
disable_attention_slicing[[diffusers.StableDiffusionDepth2ImgPipeline.disable_attention_slicing]]
disable_attention_slicing()
์ฌ๋ผ์ด์ค๋ ์ดํ
์
๊ณ์ฐ ๊ธฐ๋ฅ์ ๋นํ์ฑํํฉ๋๋ค. enable_attention_slicing๊ฐ ์ด์ ์ ํธ์ถ๋ ๊ฒฝ์ฐ, ์ดํ
์
์ ํ ๋ฒ์ ๊ณ์ฐ๋ฉ๋๋ค.
enable_xformers_memory_efficient_attention[[diffusers.StableDiffusionDepth2ImgPipeline.enable_xformers_memory_efficient_attention]]
enable_xformers_memory_efficient_attention(attention_op: typing.Optional[typing.Callable] = None)
๋งค๊ฐ๋ณ์:
attention_op (Callable, ์ ํ ์ฌํญ) : xFormers์ memory_efficient_attention() ํจ์์ op ์ธ์๋ก ์ฌ์ฉ๋ ๋ ๊ธฐ๋ณธ None ์ฐ์ฐ์๋ฅผ ์ฌ์ ์ํฉ๋๋ค.
xFormers์์ ๋ฉ๋ชจ๋ฆฌ ํจ์จ์ ์ธ ์ดํ ์ ์ ํ์ฑํํฉ๋๋ค. ์ด ์ต์ ์ ํ์ฑํํ๋ฉด ์ถ๋ก ์ GPU ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋์ด ๊ฐ์ํ๊ณ ์๋๊ฐ ํฅ์๋ ์ ์์ต๋๋ค. ํ์ต ์ ์๋ ํฅ์์ ๋ณด์ฅ๋์ง ์์ต๋๋ค.
> โ ๏ธ memory efficient attention๊ณผ sliced attention์ด ๋ชจ๋ ํ์ฑํ๋ ๊ฒฝ์ฐ, memory efficient attention์ > ์ฐ์ ์์๋ฅผ ๊ฐ์ง๋๋ค.
์:
>>> import torch
>>> from diffusers import DiffusionPipeline
>>> from xformers.ops import MemoryEfficientAttentionFlashAttentionOp
>>> pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1", dtype=torch.float16)
>>> pipe = pipe.to("cuda")
>>> pipe.enable_xformers_memory_efficient_attention(attention_op=MemoryEfficientAttentionFlashAttentionOp)
>>> # Workaround for not accepting attention shape using VAE for Flash Attention
>>> pipe.vae.enable_xformers_memory_efficient_attention(attention_op=None)
disable_xformers_memory_efficient_attention[[diffusers.StableDiffusionDepth2ImgPipeline.disable_xformers_memory_efficient_attention]]
disable_xformers_memory_efficient_attention()
xFormers์์ ๋ฉ๋ชจ๋ฆฌ ํจ์จ์ ์ดํ ์ ์ ๋นํ์ฑํํฉ๋๋ค.
load_textual_inversion[[diffusers.StableDiffusionDepth2ImgPipeline.load_textual_inversion]]
load_textual_inversion(pretrained_model_name_or_path: str | list[str] | dict[str, torch.Tensor] | list[dict[str, torch.Tensor]], token: str | list[str] | None = None, tokenizer: 'PreTrainedTokenizer' | None = None, text_encoder: 'PreTrainedModel' | None = None, **kwargs)
๋งค๊ฐ๋ณ์:
pretrained_model_name_or_path (str ๋๋ os.PathLike ๋๋ list[str or os.PathLike] ๋๋ Dict ๋๋ list[Dict]) : ๋ค์ ์ค ํ๋์ด๊ฑฐ๋, ์ด๋ค์ ๋ฆฌ์คํธ์ผ ์ ์์ต๋๋ค: - Hub์ ํธ์คํ
๋ ์ฌ์ ํ์ต ๋ชจ๋ธ์ model id ๋ฌธ์์ด (์: sd-concepts-library/low-poly-hd-logos-icons). - ํ
์คํธ ์ธ๋ฒ์ ๊ฐ์ค์น๋ฅผ ํฌํจํ๋ ๋๋ ํฐ๋ฆฌ ๊ฒฝ๋ก (์: ./my_text_inversion_directory/). - ํ
์คํธ ์ธ๋ฒ์ ๊ฐ์ค์น๋ฅผ ํฌํจํ๋ ํ์ผ ๊ฒฝ๋ก (์: ./my_text_inversions.pt). - torch state dict.
token (str ๋๋ list[str], ์ ํ ์ฌํญ) : ํ
์คํธ ์ธ๋ฒ์ ๊ฐ์ค์น์ ์ฌ์ฉํ ํ ํฐ์ ์ฌ์ ์ํฉ๋๋ค. pretrained_model_name_or_path๊ฐ ๋ฆฌ์คํธ์ธ ๊ฒฝ์ฐ, token๋ ๋์ผํ ๊ธธ์ด์ ๋ฆฌ์คํธ์ฌ์ผ ํฉ๋๋ค.
text_encoder (CLIPTextModel, ์ ํ ์ฌํญ) : ๋๊ฒฐ๋ ํ ์คํธ ์ธ์ฝ๋(clip-vit-large-patch14). ์ง์ ๋์ง ์์ผ๋ฉด ํจ์๊ฐ self.tokenizer๋ฅผ ์ฌ์ฉํฉ๋๋ค.
tokenizer (CLIPTokenizer, ์ ํ ์ฌํญ) : ํ
์คํธ๋ฅผ ํ ํฐํํ CLIPTokenizer์
๋๋ค. ์ง์ ํ์ง ์์ผ๋ฉด ํจ์๊ฐ self.tokenizer๋ฅผ ์ฌ์ฉํฉ๋๋ค.
weight_name (str, ์ ํ ์ฌํญ) : ์ปค์คํ
๊ฐ์ค์น ํ์ผ์ ์ด๋ฆ. ๋ค์ ๊ฒฝ์ฐ์ ์ฌ์ฉํด์ผ ํฉ๋๋ค: - ์ ์ฅ๋ ํ
์คํธ ์ธ๋ฒ์ ํ์ผ์ด ๐ค Diffusers ํ์์ด์ง๋ง text_inv.bin๊ณผ ๊ฐ์ ํน์ ๊ฐ์ค์น ์ด๋ฆ์ผ๋ก ์ ์ฅ๋ ๊ฒฝ์ฐ. - ์ ์ฅ๋ ํ
์คํธ ์ธ๋ฒ์ ํ์ผ์ด Automatic1111 ํ์์ธ ๊ฒฝ์ฐ.
cache_dir (str | os.PathLike, ์ ํ ์ฌํญ) : ํ์ค ์บ์๋ฅผ ์ฌ์ฉํ์ง ์์ ๊ฒฝ์ฐ, ๋ค์ด๋ก๋๋ ์ฌ์ ํ์ต ๋ชจ๋ธ ๊ตฌ์ฑ์ด ์บ์๋๋ ๋๋ ํฐ๋ฆฌ์ ๊ฒฝ๋ก์
๋๋ค.
force_download (bool, ์ ํ ์ฌํญ, ๊ธฐ๋ณธ๊ฐ False) : ์บ์๋ ๋ฒ์ ์ด ์กด์ฌํ๋๋ผ๋ ๋ชจ๋ธ ๊ฐ์ค์น ๋ฐ ๊ตฌ์ฑ ํ์ผ์ (์ฌ)๋ค์ด๋ก๋๋ฅผ ๊ฐ์ ํ ์ง ์ฌ๋ถ.
proxies (dict[str, str], ์ ํ ์ฌํญ) : ํ๋กํ ์ฝ ๋๋ ์๋ํฌ์ธํธ๋ณ๋ก ์ฌ์ฉํ ํ๋ก์ ์๋ฒ์ ์ฌ์ ์
๋๋ค. ์๋ฅผ ๋ค์ด, {'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}์ ๊ฐ์ต๋๋ค. ๊ฐ ์์ฒญ์ ํ๋ก์๊ฐ ์ฌ์ฉ๋ฉ๋๋ค.
local_files_only (bool, ์ ํ ์ฌํญ, ๊ธฐ๋ณธ๊ฐ False) : ๋ก์ปฌ ๋ชจ๋ธ ๊ฐ์ค์น์ ๊ตฌ์ฑ ํ์ผ๋ง ๋ก๋ํ ์ง ์ฌ๋ถ๋ฅผ ์ง์ ํฉ๋๋ค. True๋ก ์ค์ ํ๋ฉด Hub์์ ๋ชจ๋ธ์ ๋ค์ด๋ก๋ํ์ง ์์ต๋๋ค.
hf_token (str ๋๋ bool, ์ ํ ์ฌํญ) : ์๊ฒฉ ํ์ผ์ ๋ํ HTTP bearer ์ธ์ฆ์ผ๋ก ์ฌ์ฉํ ํ ํฐ์
๋๋ค. True์ธ ๊ฒฝ์ฐ, diffusers-cli login์์ ์์ฑ๋ ํ ํฐ(~/.huggingface์ ์ ์ฅ๋จ)์ด ์ฌ์ฉ๋ฉ๋๋ค.
revision (str, ์ ํ ์ฌํญ, ๊ธฐ๋ณธ๊ฐ "main") : ์ฌ์ฉํ ํน์ ๋ชจ๋ธ ๋ฒ์ ์
๋๋ค. Git์์ ํ์ฉํ๋ ๋ธ๋์น ์ด๋ฆ, ํ๊ทธ ์ด๋ฆ, ์ปค๋ฐ ID ๋๋ ๊ธฐํ ์๋ณ์์ผ ์ ์์ต๋๋ค.
subfolder (str, ์ ํ ์ฌํญ, ๊ธฐ๋ณธ๊ฐ "") : Hub ๋๋ ๋ก์ปฌ์ ๋ ํฐ ๋ชจ๋ธ ์ ์ฅ์ ๋ด์์ ๋ชจ๋ธ ํ์ผ์ ์๋ธํด๋ ์์น์
๋๋ค.
mirror (str, ์ ํ ์ฌํญ) : ์ค๊ตญ์์ ๋ชจ๋ธ์ ๋ค์ด๋ก๋ํ ๋ ์ ๊ทผ์ฑ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํ ๋ฏธ๋ฌ ์์ค์
๋๋ค. ํด๋น ์์ค์ ์ ์์ฑ์ด๋ ์์ ์ฑ์ ๋ณด์ฅํ์ง ์์ผ๋ฉฐ, ์์ธํ ๋ด์ฉ์ ๋ฏธ๋ฌ ์ฌ์ดํธ๋ฅผ ์ฐธ๊ณ ํ์ธ์.
StableDiffusionPipeline์ ํ ์คํธ ์ธ์ฝ๋์ Textual Inversion ์๋ฒ ๋ฉ์ ๋ก๋ํฉ๋๋ค(๐ค Diffusers์ Automatic1111 ํ์ ๋ชจ๋ ์ง์).
์:
๐ค Diffusers ํ์์ผ๋ก Textual Inversion ์๋ฒ ๋ฉ ๋ฒกํฐ๋ฅผ ๋ก๋ํ๋ ค๋ฉด:
from diffusers import StableDiffusionPipeline
import torch
model_id = "stable-diffusion-v1-5/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda")
pipe.load_textual_inversion("sd-concepts-library/cat-toy")
prompt = "A <cat-toy> backpack"
image = pipe(prompt, num_inference_steps=50).images[0]
image.save("cat-backpack.png")
Automatic1111 ํ์์ Textual Inversion ์๋ฒ ๋ฉ ๋ฒกํฐ๋ฅผ ๋ก๋ํ๋ ค๋ฉด ๋จผ์ ๋ฒกํฐ๋ฅผ ๋ค์ด๋ก๋(์: civitAI์์)ํ ๋ค์ ๋ฒกํฐ๋ฅผ ๋ก๋ํด์ผ ํฉ๋๋ค.
๋ก์ปฌ์์:
from diffusers import StableDiffusionPipeline
import torch
model_id = "stable-diffusion-v1-5/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda")
pipe.load_textual_inversion("./charturnerv2.pt", token="charturnerv2")
prompt = "charturnerv2, multiple views of the same character in the same outfit, a character turnaround of a woman wearing a black jacket and red shirt, best quality, intricate details."
image = pipe(prompt, num_inference_steps=50).images[0]
image.save("character.png")
load_lora_weights[[diffusers.StableDiffusionDepth2ImgPipeline.load_lora_weights]]
load_lora_weights(pretrained_model_name_or_path_or_dict: str | dict[str, torch.Tensor], adapter_name: str | None = None, hotswap: bool = False, **kwargs)
๋งค๊ฐ๋ณ์:
pretrained_model_name_or_path_or_dict (str ๋๋ os.PathLike ๋๋ dict) : lora_state_dict()์(๋ฅผ) ์ฐธ์กฐํ์ธ์.
adapter_name (str, ์ ํ ์ฌํญ) : ๋ก๋๋ ์ด๋ํฐ ๋ชจ๋ธ์ ์ฐธ์กฐํ ๋ ์ฌ์ฉํ ์ด๋ํฐ ์ด๋ฆ. ์ง์ ํ์ง ์์ผ๋ฉด ๋ก๋ ์ค์ธ ์ด๋ํฐ์ ์ด ๊ฐ์๋ฅผ i๋ผ๊ณ ํ ๋ default_{i}๊ฐ ์ฌ์ฉ๋ฉ๋๋ค.
low_cpu_mem_usage (bool, ์ ํ ์ฌํญ) : ๋ฌด์์ ๊ฐ์ค์น๋ฅผ ์ด๊ธฐํํ์ง ์๊ณ ์ฌ์ ํ์ต๋ LoRA ๊ฐ์ค์น๋ง ๋ก๋ํ์ฌ ๋ชจ๋ธ ๋ก๋ฉ ์๋๋ฅผ ๋์
๋๋ค.
hotswap (bool, ์ ํ ์ฌํญ) : ๊ธฐ๋ณธ๊ฐ์ False์
๋๋ค. ๊ธฐ์กด (LoRA) ์ด๋ํฐ๋ฅผ ์๋ก ๋ก๋ํ ์ด๋ํฐ๋ก ์ ์๋ฆฌ์์ ๊ต์ฒดํ ์ง ์ฌ๋ถ์
๋๋ค. ์ฆ, ์ถ๊ฐ ์ด๋ํฐ๋ฅผ ๋ก๋ํ๋ ๋์ ๊ธฐ์กด ์ด๋ํฐ์ ๊ฐ์ค์น๋ฅผ ์ ์ด๋ํฐ์ ๊ฐ์ค์น๋ก ๋์ฒดํฉ๋๋ค. ์ด๋ ๋ ๋น ๋ฅด๊ณ ๋ฉ๋ชจ๋ฆฌ ํจ์จ์ ์ผ ์ ์์ต๋๋ค. ๊ทธ๋ฌ๋ ํซ์ค์์ ์ฃผ์ ์ด์ ์ ๋ชจ๋ธ์ด torch.compile๋ก ์ปดํ์ผ๋ ๊ฒฝ์ฐ, ์ ์ด๋ํฐ๋ฅผ ๋ก๋ํ ๋ ๋ชจ๋ธ์ ์ฌ์ปดํ์ผ์ด ํ์ํ์ง ์๋ค๋ ์ ์
๋๋ค. ํซ์ค์์ ์ฌ์ฉํ ๋ ์ ๋ฌํ๋ adapter_name์ ์ด๋ฏธ ๋ก๋๋ ์ด๋ํฐ์ ์ด๋ฆ์ด์ด์ผ ํฉ๋๋ค. ์ ์ด๋ํฐ์ ๊ธฐ์กด ์ด๋ํฐ์ ๋ญํฌ์/๋๋ LoRA ์ํ(์ฆ, ์ค์ผ์ผ๋ง)๊ฐ ๋ค๋ฅธ ๊ฒฝ์ฐ, ์ด๋ํฐ๋ฅผ ๋ก๋ํ๊ธฐ ์ ์ ์ถ๊ฐ ๋ฉ์๋๋ฅผ ํธ์ถํด์ผ ํฉ๋๋ค: py pipeline = ... # load diffusers pipeline max_rank = ... # the highest rank among all LoRAs that you want to load # call *before* compiling and loading the LoRA adapter pipeline.enable_lora_hotswap(target_rank=max_rank) pipeline.load_lora_weights(file_name) # optionally compile the model now ํ
์คํธ ์ธ์ฝ๋์ ์ด๋ํฐ ํซ์ค์์ ์์ง ์ง์๋์ง ์์ต๋๋ค. ์ด ๊ธฐ๋ฒ์๋ ๋ช ๊ฐ์ง ์ถ๊ฐ ์ ํ ์ฌํญ์ด ์์ผ๋ฉฐ, ์ฌ๊ธฐ์์ ๋ฌธ์ํ๋์ด ์์ต๋๋ค: https://huggingface.co/docs/peft/main/en/package_reference/hotswap
kwargs (dict, ์ ํ ์ฌํญ) : lora_state_dict()๋ฅผ ์ฐธ์กฐํ์ธ์.
pretrained_model_name_or_path_or_dict์ ์ง์ ๋ LoRA ๊ฐ์ค์น๋ฅผ self.unet์ self.text_encoder์ ๋ก๋ํฉ๋๋ค.
๋ชจ๋ kwargs๋ self.lora_state_dict๋ก ์ ๋ฌ๋ฉ๋๋ค.
state dict๊ฐ ๋ก๋๋๋ ๋ฐฉ๋ฒ์ ๋ํ ์์ธํ ๋ด์ฉ์ lora_state_dict()์ ์ฐธ์กฐํ์ธ์.
self.unet์ ์ํ ์ฌ์ ์ด ๋ก๋๋๋ ๋ฐฉ๋ฒ์ ๋ํ ์์ธํ ๋ด์ฉ์ load_lora_into_unet()์ ์ฐธ์กฐํ์ญ์์ค.
self.text_encoder์ state dict๊ฐ ๋ก๋๋๋ ๋ฐฉ๋ฒ์ ๋ํ ์์ธํ ๋ด์ฉ์ load_lora_into_text_encoder()๋ฅผ ์ฐธ์กฐํ์ธ์.
save_lora_weights[[diffusers.StableDiffusionDepth2ImgPipeline.save_lora_weights]]
save_lora_weights(save_directory: str | os.PathLike, unet_lora_layers: dict[str, typing.Union[torch.nn.Module, torch.Tensor]] = None, text_encoder_lora_layers: dict[str, torch.nn.Module] = None, is_main_process: bool = True, weight_name: str = None, save_function: typing.Callable = None, safe_serialization: bool = True, unet_lora_adapter_metadata = None, text_encoder_lora_adapter_metadata = None)
๋งค๊ฐ๋ณ์:
save_directory (str ๋๋ os.PathLike) : LoRA ํ๋ผ๋ฏธํฐ๋ฅผ ์ ์ฅํ ๋๋ ํฐ๋ฆฌ์
๋๋ค. ์กด์ฌํ์ง ์์ผ๋ฉด ์์ฑ๋ฉ๋๋ค.
unet_lora_layers (dict[str, torch.nn.Module] ๋๋ dict[str, torch.Tensor]) : unet์ ํด๋นํ๋ LoRA ๋ ์ด์ด์ state dict์
๋๋ค.
text_encoder_lora_layers (dict[str, torch.nn.Module] ๋๋ dict[str, torch.Tensor]) : text_encoder์ ํด๋นํ๋ LoRA ๋ ์ด์ด์ state dict์
๋๋ค. ๐ค Transformers์์ ๊ฐ์ ธ์ค๋ฏ๋ก text encoder LoRA state dict๋ฅผ ๋ช
์์ ์ผ๋ก ์ ๋ฌํด์ผ ํฉ๋๋ค.
is_main_process (bool, ์ ํ ์ฌํญ, ๊ธฐ๋ณธ๊ฐ True) : ์ด ํจ์๋ฅผ ํธ์ถํ๋ ํ๋ก์ธ์ค๊ฐ ๋ฉ์ธ ํ๋ก์ธ์ค์ธ์ง ์ฌ๋ถ์
๋๋ค. ๋ถ์ฐ ํ์ต ์ค์ ๋ชจ๋ ํ๋ก์ธ์ค์์ ์ด ํจ์๋ฅผ ํธ์ถํด์ผ ํ๋ ๊ฒฝ์ฐ ์ ์ฉํฉ๋๋ค. ์ด ๊ฒฝ์ฐ ๋ ์ด์ค ์กฐ๊ฑด์ ๋ฐฉ์งํ๊ธฐ ์ํด ๋ฉ์ธ ํ๋ก์ธ์ค์์๋ง is_main_process=True๋ก ์ค์ ํ์ธ์.
save_function (Callable) : ์ํ ์ฌ์ (state dictionary)์ ์ ์ฅํ๋ ๋ฐ ์ฌ์ฉํ ํจ์์
๋๋ค. ๋ถ์ฐ ํ์ต ์ค์ torch.save๋ฅผ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ผ๋ก ๋์ฒดํด์ผ ํ๋ ๊ฒฝ์ฐ ์ ์ฉํฉ๋๋ค. ํ๊ฒฝ ๋ณ์ DIFFUSERS_SAVE_MODE๋ก ์ค์ ํ ์ ์์ต๋๋ค.
safe_serialization (bool, ์ ํ ์ฌํญ, ๊ธฐ๋ณธ๊ฐ True) : safetensors ๋๋ pickle๋ฅผ ์ฌ์ฉํ ์ ํต์ ์ธ PyTorch ๋ฐฉ์์ผ๋ก ๋ชจ๋ธ์ ์ ์ฅํ ์ง ์ฌ๋ถ.
unet_lora_adapter_metadata : state dict์ ํจ๊ป ์ง๋ ฌํ๋ unet์ ์ฐ๊ฒฐ๋ LoRA ์ด๋ํฐ ๋ฉํ๋ฐ์ดํฐ.
text_encoder_lora_adapter_metadata : state dict์ ํจ๊ป ์ง๋ ฌํ๋ ํ ์คํธ ์ธ์ฝ๋์ ๊ด๋ จ๋ LoRA ์ด๋ํฐ ๋ฉํ๋ฐ์ดํฐ.
UNet๊ณผ ํ ์คํธ ์ธ์ฝ๋์ ํด๋นํ๋ LoRA ๋งค๊ฐ๋ณ์๋ฅผ ์ ์ฅํฉ๋๋ค.
encode_prompt[[diffusers.StableDiffusionDepth2ImgPipeline.encode_prompt]]
encode_prompt(prompt, device, num_images_per_prompt, do_classifier_free_guidance, negative_prompt = None, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, lora_scale: float | None = None, clip_skip: int | None = None)
๋งค๊ฐ๋ณ์:
prompt (str ๋๋ list[str], ์ ํ ์ฌํญ) : ์ธ์ฝ๋ฉํ ํ๋กฌํํธ
device : (torch.device): torch ๋๋ฐ์ด์ค
num_images_per_prompt (int) : ํ๋กฌํํธ๋น ์์ฑํ ์ด๋ฏธ์ง ์
do_classifier_free_guidance (bool) : classifier free guidance๋ฅผ ์ฌ์ฉํ ์ง ์ฌ๋ถ
negative_prompt (str ๋๋ list[str], ์ ํ ์ฌํญ) : ์ด๋ฏธ์ง ์์ฑ์ ์๋ดํ์ง ์์ ํ๋กฌํํธ์
๋๋ค. ์ ์๋์ง ์์ ๊ฒฝ์ฐ ๋์ negative_prompt_embeds๋ฅผ ์ ๋ฌํด์ผ ํฉ๋๋ค. ๊ฐ์ด๋์ค๋ฅผ ์ฌ์ฉํ์ง ์๋ ๊ฒฝ์ฐ ๋ฌด์๋ฉ๋๋ค(์ฆ, guidance_scale์ด 1๋ณด๋ค ์์ ๊ฒฝ์ฐ ๋ฌด์๋ฉ๋๋ค).
prompt_embeds (torch.Tensor, ์ ํ ์ฌํญ) : ๋ฏธ๋ฆฌ ์์ฑ๋ ํ
์คํธ ์๋ฒ ๋ฉ์
๋๋ค. ์๋ฅผ ๋ค์ด ํ๋กฌํํธ ๊ฐ์ค์น์ ๊ฐ์ ํ
์คํธ ์
๋ ฅ์ ์ฝ๊ฒ ์กฐ์ ํ๋ ๋ฐ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ ๊ณต๋์ง ์์ผ๋ฉด prompt ์
๋ ฅ ์ธ์์์ ํ
์คํธ ์๋ฒ ๋ฉ์ด ์์ฑ๋ฉ๋๋ค.
negative_prompt_embeds (torch.Tensor, ์ ํ ์ฌํญ) : ๋ฏธ๋ฆฌ ์์ฑ๋ ๋ถ์ ํ
์คํธ ์๋ฒ ๋ฉ์
๋๋ค. ํ
์คํธ ์
๋ ฅ์ ์ฝ๊ฒ ์กฐ์ ํ๋ ๋ฐ ์ฌ์ฉํ ์ ์์ผ๋ฉฐ, ์๋ฅผ ๋ค์ด ํ๋กฌํํธ ๊ฐ์ค์น ์ค์ ์ ํ์ฉํ ์ ์์ต๋๋ค. ์ ๊ณต๋์ง ์์ผ๋ฉด negative_prompt ์
๋ ฅ ์ธ์์์ negative_prompt_embeds๊ฐ ์์ฑ๋ฉ๋๋ค.
lora_scale (float, ์ ํ ์ฌํญ) : LoRA ๋ ์ด์ด๊ฐ ๋ก๋๋ ๊ฒฝ์ฐ ํ
์คํธ ์ธ์ฝ๋์ ๋ชจ๋ LoRA ๋ ์ด์ด์ ์ ์ฉ๋ LoRA ์ค์ผ์ผ์
๋๋ค.
clip_skip (int, ์ ํ ์ฌํญ) : ํ๋กฌํํธ ์๋ฒ ๋ฉ์ ๊ณ์ฐํ ๋ CLIP์์ ๊ฑด๋๋ธ ๋ ์ด์ด ์. ๊ฐ์ด 1์ด๋ฉด ์ต์ข
๋ ์ด์ด ๋ฐ๋ก ์ด์ ๋ ์ด์ด์ ์ถ๋ ฅ์ ํ๋กฌํํธ ์๋ฒ ๋ฉ ๊ณ์ฐ์ ์ฌ์ฉํฉ๋๋ค.
ํ๋กฌํํธ๋ฅผ ํ ์คํธ ์ธ์ฝ๋์ ํ๋ ์ํ๋ก ์ธ์ฝ๋ฉํฉ๋๋ค.
StableDiffusionPipelineOutput[[diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput]]
diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput[[diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput]]
diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput(images: list[PIL.Image.Image] | numpy.ndarray, nsfw_content_detected: list[bool] | None)
๋งค๊ฐ๋ณ์:
images (list[PIL.Image.Image] ๋๋ np.ndarray) : batch_size ๊ธธ์ด์ ๋
ธ์ด์ฆ ์ ๊ฑฐ๋ PIL ์ด๋ฏธ์ง ๋ชฉ๋ก ๋๋ (batch_size, height, width, num_channels) ๋ชจ์์ NumPy ๋ฐฐ์ด.
nsfw_content_detected (list[bool]) : ํด๋น ์์ฑ๋ ์ด๋ฏธ์ง์ "not-safe-for-work"(nsfw) ์ฝํ
์ธ ๊ฐ ํฌํจ๋์ด ์๋์ง ์ฌ๋ถ๋ฅผ ๋ํ๋ด๋ ๋ฆฌ์คํธ. ์์ ๊ฒ์ฌ๋ฅผ ์ํํ ์ ์๋ ๊ฒฝ์ฐ None.
Stable Diffusion ํ์ดํ๋ผ์ธ์ ์ถ๋ ฅ ํด๋์ค์ ๋๋ค.
Xet Storage Details
- Size:
- 30.7 kB
- Xet hash:
- d955ad78dafa3287a62cb8cf74d6e885075bb924c1b272efc01989d34b4c9ddb
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.