|
# ์ด๋ฏธ์ง ๋ฐ๊ธฐ ์กฐ์ ํ๊ธฐ |
|
|
|
Stable Diffusion ํ์ดํ๋ผ์ธ์ [์ผ๋ฐ์ ์ธ ๋ํจ์ ๋
ธ์ด์ฆ ์ค์ผ์ค๊ณผ ์ํ ๋จ๊ณ์ ๊ฒฐํจ์ด ์์](https://huggingface.co/papers/2305.08891) ๋
ผ๋ฌธ์์ ์ค๋ช
ํ ๊ฒ์ฒ๋ผ ๋งค์ฐ ๋ฐ๊ฑฐ๋ ์ด๋์ด ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ ๋ฐ๋ ์ฑ๋ฅ์ด ํ๋ฒํฉ๋๋ค. ์ด ๋
ผ๋ฌธ์์ ์ ์ํ ์๋ฃจ์
์ ํ์ฌ [`DDIMScheduler`]์ ๊ตฌํ๋์ด ์์ผ๋ฉฐ ์ด๋ฏธ์ง์ ๋ฐ๊ธฐ๋ฅผ ๊ฐ์ ํ๋ ๋ฐ ์ฌ์ฉํ ์ ์์ต๋๋ค. |
|
|
|
<Tip> |
|
|
|
๐ก ์ ์๋ ์๋ฃจ์
์ ๋ํ ์์ธํ ๋ด์ฉ์ ์์ ๋งํฌ๋ ๋
ผ๋ฌธ์ ์ฐธ๊ณ ํ์ธ์! |
|
|
|
</Tip> |
|
|
|
ํด๊ฒฐ์ฑ
์ค ํ๋๋ *v ์์ธก๊ฐ*๊ณผ *v ๋ก์ค*๋ก ๋ชจ๋ธ์ ํ๋ จํ๋ ๊ฒ์
๋๋ค. ๋ค์ flag๋ฅผ [`train_text_to_image.py`](https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image.py) ๋๋ [`train_text_to_image_lora.py`](https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image_lora.py) ์คํฌ๋ฆฝํธ์ ์ถ๊ฐํ์ฌ `v_prediction`์ ํ์ฑํํฉ๋๋ค: |
|
|
|
```bash |
|
--prediction_type="v_prediction" |
|
``` |
|
|
|
์๋ฅผ ๋ค์ด, `v_prediction`์ผ๋ก ๋ฏธ์ธ ์กฐ์ ๋ [`ptx0/pseudo-journey-v2`](https://huggingface.co/ptx0/pseudo-journey-v2) ์ฒดํฌํฌ์ธํธ๋ฅผ ์ฌ์ฉํด ๋ณด๊ฒ ์ต๋๋ค. |
|
|
|
๋ค์์ผ๋ก [`DDIMScheduler`]์์ ๋ค์ ํ๋ผ๋ฏธํฐ๋ฅผ ์ค์ ํฉ๋๋ค: |
|
|
|
1. rescale_betas_zero_snr=True`, ๋
ธ์ด์ฆ ์ค์ผ์ค์ ์ ๋ก ํฐ๋ฏธ๋ ์ ํธ ๋ ์ก์๋น(SNR)๋ก ์ฌ์กฐ์ ํฉ๋๋ค. |
|
2. `timestep_spacing="trailing"`, ๋ง์ง๋ง ํ์์คํ
๋ถํฐ ์ํ๋ง ์์ |
|
|
|
```py |
|
>>> from diffusers import DiffusionPipeline, DDIMScheduler |
|
|
|
>>> pipeline = DiffusionPipeline.from_pretrained("ptx0/pseudo-journey-v2") |
|
# switch the scheduler in the pipeline to use the DDIMScheduler |
|
|
|
>>> pipeline.scheduler = DDIMScheduler.from_config( |
|
... pipeline.scheduler.config, rescale_betas_zero_snr=True, timestep_spacing="trailing" |
|
... ) |
|
>>> pipeline.to("cuda") |
|
``` |
|
|
|
๋ง์ง๋ง์ผ๋ก ํ์ดํ๋ผ์ธ์ ๋ํ ํธ์ถ์์ `guidance_rescale`์ ์ค์ ํ์ฌ ๊ณผ๋ค ๋
ธ์ถ์ ๋ฐฉ์งํฉ๋๋ค: |
|
|
|
```py |
|
prompt = "A lion in galaxies, spirals, nebulae, stars, smoke, iridescent, intricate detail, octane render, 8k" |
|
image = pipeline(prompt, guidance_rescale=0.7).images[0] |
|
``` |
|
|
|
<div class="flex justify-center"> |
|
<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/zero_snr.png"/> |
|
</div> |