outpainting ์—๋Š” ์—ฌ๋Ÿฌ ๋ฐฉ๋ฒ•์ด ์žˆ์—ˆ๋‹ค.

1. ์ฒ˜์Œ์‹œ๋„ํ•œ ๋ฐฉ๋ฒ•์€ https://github.com/lkwq007/stablediffusion-infinity.git

 

GitHub - lkwq007/stablediffusion-infinity: Outpainting with Stable Diffusion on an infinite canvas

Outpainting with Stable Diffusion on an infinite canvas - GitHub - lkwq007/stablediffusion-infinity: Outpainting with Stable Diffusion on an infinite canvas

github.com

์„ค์น˜๋Š” ๊ฐ„๋‹จํ•˜๋‹ค. ๊นƒํ—™ํŽ˜์ด์ง€๋กœ ๊ฐ€์„œ ์œˆ๋„์šฐ ์„ค์น˜๋ถ€๋ถ„์„ ๊ทธ๋Œ€๋กœ ๋”ฐ๋ผํ•˜๋ฉด ๋œ๋‹ค. ๋‹ค๋งŒ ์„ค์น˜ํ•˜๋Š”๋ฐ ์‹œ๊ฐ„์ด ๋งŽ์ด ๊ฑธ๋ฆฐ๋‹ค.

๋‚˜๋Š” conda๋กœ outpaint๋ผ๋Š” ๊ฐ€์ƒํ™˜๊ฒฝ์„ ๋งŒ๋“ค๊ณ  ์—ฌ๊ธฐ์— ์„ค์น˜ํ–ˆ๋‹ค.

git clone --recurse-submodules https://github.com/lkwq007/stablediffusion-infinity
cd stablediffusion-infinity
conda create -n outpaint python=3.10
conda activate outpaint
conda install pytorch torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia
conda install scipy scikit-image
conda install -c conda-forge diffusers transformers ftfy accelerate
pip install opencv-python
pip install -U gradio
pip install pytorch-lightning==1.7.7 einops==0.4.1 omegaconf==2.2.3
pip install timm

infinity๋ฅผ ์‚ฌ์šฉํ•ด ์•„๋ž˜์˜ ์›๋ณธ ์ด๋ฏธ์ง€๋ฅผ ๊ทธ ์•„๋ž˜์˜ ์ด๋ฏธ์ฒ˜๋Ÿผ ํ™•์žฅ์‹œํ‚ฌ์ˆ˜ ์žˆ๋‹ค. ์—„์ฒญ๋‚˜๋‹ค. 

์‚ฌ์šฉ๋ฒ•์€ ํ˜ผ์ž ๊ทธ๋ƒฅ ๋งŒ์ง€๋ฉฐ ์ตํ˜”๋‹ค. ๋‚˜์ค‘์— ์œ ํŠœ๋ธŒ๋ฅผ ์ฐพ์•„๋ณด๋‹ˆ ๋‚˜์™€ ๋‹ค๋ฅผ๋ฐ” ์—†์—ˆ๋‹ค. 

๋งŒ๋“ค๋•Œ ๊ผญ ์ฒ˜์Œ ์ € ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ• ๋•Œ์˜ ํ”„๋กฌํ”„ํŠธ๋„ ๊ฐ™์ด ๋„ฃ์–ด์•ผ ์–ด์ƒ‰ํ•˜๊ฒŒ ์•ˆ๋‚˜์˜จ๋‹ค.
๊ทธ๋ฆฌ๊ณ  ๊ธฐ์กด ์ด๋ฏธ์ง€ ์ •๋ณด๋„ ํ•จ๊ป˜ ๋งŽ์ด ํฌํ•จํ•ด์ค˜์•ผ(์„ ํƒํ•ด์ค˜์•ผ) ์ž์—ฐ์Šค๋Ÿฌ์›Œ์ง„๋‹ค.

ํ•˜์ง€๋งŒ ์‹œ๊ฐ„์ด ์•„์ฃผ ์˜ค๋ž˜ ๊ฑธ๋ฆฐ๋‹ค. ๋งˆ์Œ์— ๋“ค์ง€ ์•Š๋Š” ๊ทธ๋ฆผ์ด ๋‚˜์˜ฌ๋•Œ๋„ ๋งŽ๋‹ค. ๊ทธ๋ž˜์„œ ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•์„ ์ฐพ์•„๋ดค๋‹ค.

 

2. ๊ธฐ์กด ์ด๋ฏธ์ง€์˜ canvas๋ฅผ ๋Š˜๋ฆฌ๊ณ  ๊ทธ ๋ถ€๋ถ„์„ ์ƒ‰์น ํ•œ ๋‹ค์Œ ์ด ๋ถ€๋ถ„๋งŒ img2img์—์„œ ๋‹ค์‹œ ์ƒ์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค.

์ด์ œ ์ œ์ผ ์ข‹์„ ๊ฑฐ๋ผ ์ƒ๊ฐํ–ˆ๋Š”๋ฐ ๋” ์ข‹์€ ๋ฐฉ๋ฒ•์„ ์ฐพ์•„๋ƒˆ๋‹ค.

 

3. ์ถ”๊ฐ€ ์„ค์น˜ํ•  ๊ฒƒ๋„ ์—†๋‹ค. ๋ฐ”๋กœ stable diffusion > img2img ์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

ํ™˜์ƒ์ ์ด๋‹ค. ์†๋„๋„ ๋น ๋ฅด๋‹ค.

img2img๋ฅผ ๊ฐ€๋ฉด ๋งจ ์•„๋ž˜์— Script๋ฅผ ์„ ํƒํ•˜๋Š” ๋ถ€๋ถ„์ด ์žˆ๋‹ค.

์—ฌ๊ธฐ์„œ Outpaing mk2๋กœ ์„ ํƒํ•œ๋‹ค. ์•„๋ž˜์™€ ๊ฐ™์€ ์„ ํƒ์ฐฝ์ด ๋œจ๋Š”๋ฐ ๋ฐ”๊พธ ์•Š๋Š”๊ฒŒ ๊ฐ€์žฅ ์ข‹๋”๋ผ.
๋‹จ ๋ฐฉํ–ฅ์€ ํ•œ ๋ฐฉํ–ฅ์”ฉ ๋Š˜๋ ค๊ฐ€๋ฉด์„œ ํ…Œ์ŠคํŠธํ•˜๋Š”๊ฒŒ ์ข‹๋‹ค. ์•„๋ž˜์ฒ˜๋Ÿผ left ๋จผ์ €ํ•˜๊ณ  ๋‹ค์Œ right ๋Œ๋ ค๋ณด๋Š” ๋ฐฉ์‹์ด๋‹ค.

๋‹ค ๋œ๊ฑฐ๋‹ค. ๊ทธ๋ƒฅ ์ƒ์„ฑํ•˜๋ฉด ๋œ๋‹ค. ์™ผ์ชฝ์œผ๋กœ ๋” ๋Š˜๋ฆฌ๊ณ  ์‹ถ๋‹ค๋ฉด ๊ฒฐ๊ณผ์ฐฝ์—์„œ ๋‹ค์‹œํ•œ๋ฒˆ send to img2img ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ๋ณด๋‚ธํ›„ ๊ฑฐ๊ธฐ์„œ ๋‹ค์‹œ ์ƒ์„ฑํ•˜๋ฉด ๋œ๋‹ค.
๊ฐ€์žฅ ์ข‹์€ ์ ์€ ๊ธฐ์กด๊ณผ ์™„์ „ํžˆ ๋˜‘๊ฐ™์€ ํ”„๋กฌํ”„ํŠธ์™€ ์ฒดํฌํฌ์ธํŠธ, ๋กœ๋ผ ๋ฐ ๊ฐ์ข… ์„ค์ •์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ธฐ์กด ์ด๋ฏธ์˜ ๋Š๋‚Œ์„ ์‚ด๋ฆฌ๊ธฐ ์‰ฝ๋‹ค๋Š” ๊ฑฐ๋‹ค.
๊ทธ๋ฆฌ๊ณ  infinity๋ณด๋‹ค ์†๋„๊ฐ€ ์›”๋“ฑํžˆ ๋น ๋ฅด๋‹ค. ๊ณ„์† ๋งŒ๋“ค๋ฉฐ ์‹คํ—˜ํ•˜๋ฉด ๋œ๋‹ค.

์˜์ƒ๋Œ€๋กœ ํ•˜๋ฉด ๋œ๋‹ค. ๋‹จ ๊ต์œก์‹œ๊ฐ„์ด ๊ฝค ๊ธธ๊ณ  ๋‚ด ๋ˆˆ์œผ๋กœ ๋ณด๊ธฐ์— ํ€„์ด ๋ณ„๋กœ๋‹ค.

์ด๊ฒƒ๋ณด๋‹จ ์ฐจ๋ผ๋ฆฌ Dreambooth๊ฐ€ ๋‚˜์•˜๋‹ค. ์˜์ƒ์—์„œ๋„ ๋งˆ์ง€๋ง‰์— ๋“œ๋ฆผ๋ถ€์Šค๊ฐ€ ๋‚ซ๋‹ค๊ณ  ํ‰๊ฐ€ํ•˜๊ณ  ์žˆ๋‹ค;;

 

์•„๋ž˜ 4๋Œ€ ํ›ˆ๋ จ๋ฒ• ์ค‘ Textual Inversion์„ ์ œ์™ธํ•˜๊ณ  ๋ชจ๋‘ ๋Œ๋ ค๋ดค๋Š”๋ฐ ์ด์ œ ๋” ์ด์ƒ ๊ณ ๋ฏผํ•˜์ง€ ์•Š๊ฒ ๋‹ค.

๊ทธ๋ƒฅ ๋กœ๋ผ๋ฅผ ์“ฐ์ž.

 

Extensions > Available > Load from > Dreambooth ๊ฒ€์ƒ‰

https://www.youtube.com/watch?v=tuSlUqmlZuc 

ํ”Œ๋Ÿฌ๊ทธ์ธ ๋‹ค์šด๋ฐ›์€ ํ›„ ํ”„๋กœ๊ทธ๋žจ ์žฌ์‹œ์ž‘ํ•˜๊ณ  ์œ„ ๋งํฌ๋Œ€๋กœ ๋”ฐ๋ผํ•˜๋ฉด ๋œ๋‹ค.

 

์—ฐ์˜ˆ์ธ ๋ชจ๋ธ์„ ํ›ˆ๋ จ์‹œ์ผœ๋ดค๋Š”๋ฐ ๊ฝค ์ž˜๋‚˜์™”์ง€๋งŒ 300๋ฉ”๊ฐ€๊ฐ€ ๋„˜์—ˆ๊ณ  ์‹œ๊ฐ„์€ 30๋ถ„ ์กฐ๊ธˆ ๋„˜๊ฒŒ ๊ฑธ๋ ธ๋‹ค.

์‚ฌ์šฉ๋ฒ•์€ ๊ฐ„๋‹จํ•˜์ง€๋งŒ ์‹œ๊ฐ„์ด ์ข€ ๊ฑธ๋ฆฌ๊ณ  ์šฉ๋Ÿ‰์ด ์ž‘์ง€ ์•Š๋‹ค. ๋˜ํ•œ ๊ฒฐ๊ณผ๊ฐ€ ๋กœ๋ผ๊ฐ€ ์•„๋‹Œ checkpoint ํŒŒ์ผ๋กœ ๋‚˜์˜จ๋‹ค.

* ๊ฒฐ๋ก  : ์•„๋ž˜ 4๊ฐœ์˜ ์ด๋ฏธ์ง€ ํ›ˆ๋ จ๋ฒ• ์ค‘์—์„œ dreambooth๋Š” ํƒˆ๋ฝ

 

1. webui-user.bat ํŒŒ์ผ์„ ์—ด๊ณ  --listen ์ถ”๊ฐ€. 

set COMMANDLINE_ARGS=--listen

์ด์™€ ๊ฐ™์ด ์„ค์ •ํ•˜๊ณ  ์‹คํ–‰ํ•˜๋ฉด ์•„๋ž˜์ฒ˜๋Ÿผ 7860 ํฌํŠธ๊ฐ€ ๊ธฐ๋ณธ์œผ๋กœ ์—ด๋ฆฐ๋‹ค. ๋งŒ์•ฝ ํฌํŠธ๋ฅผ 8001๋ฒˆ์œผ๋กœ ๋ฐ”๊พธ๊ณ  ์‹ถ๋‹ค๋ฉด

--listen --port 8001 ์ฒ˜๋Ÿผ ๋„ฃ์œผ๋ฉด ๋œ๋‹ค.


2. ์œˆ๋„์šฐ ๋ฐฉํ™”๋ฒฝ ์—ด๊ธฐ
๋ฐฉํ™”๋ฒฝ ์„ค์ • ๊ฒ€์ƒ‰ > ๊ณ ๊ธ‰์„ค์ •

์ธ๋ฐ”์šด๋“œ > ์ƒˆ๊ทœ์น™

ํฌํŠธ : 7860 > ๊ณ„์† ๋‹ค์Œ ํด๋ฆญ. ์ด๋ฆ„ ์ •๋„๋งŒ ๋„ฃ์–ด์ฃผ์ž.

 

3. iptime์—์„œ ํฌํŠธ ์—ด๊ธฐ

4. ์™„์„ฑ. ์ด์ œ ์™ธ๋ถ€์—์„œ ๋ถ™์–ด๋ณด์ž.

http://121.140.201.222:7860/

http://๋‚ด์•„์ดํ”ผ:ํฌํŠธ๋ฒˆํ˜ธ

 

5. ์ด์ œ ์Šค๋งˆํŠธํฐ์ด๋‚˜ ์™ธ๋ถ€PC์—์„œ๋„ ์ ‘์†ํ•  ์ˆ˜ ์žˆ๋‹ค.

* ๋งŒ์•ฝ wsl ํ™˜๊ฒฝ์ด๋ผ๋ฉด ์ถ”๊ฐ€์ ์ธ ์—ฐ๊ฒฐ ์ž‘์—…์ด ํ•„์š”ํ•˜๋‹ค. ์ฆ‰ wsl์˜ ํฌํŠธ์™€ ์œˆ๋„์šฐ์—์„œ ์˜คํ”ˆํ•œ ํฌํŠธ๋ฅผ ์—ฐ๊ฒฐํ•ด์ค˜์•ผ ํ•œ๋‹ค.
- ๊ด€๋ฆฌ์ž ๋ชจ๋“œ๋กœ ํŒŒ์›Œ์‰˜์„ ์—ฐํ›„,

netsh interface portproxy add v4tov4 listenport=wsl์—์„œ ์˜คํ”ˆํ•œ ํฌํŠธ listenaddress=0.0.0.0 connectport=์™ธ๋ถ€์—ฐ๊ฒฐํฌํŠธ connectaddress=wsl ip์ฃผ์†Œ


์‹ค์ œ ์˜ˆ์‹œ)

netsh interface portproxy add v4tov4 listenport=8001 listenaddress=0.0.0.0 connectport=8001 connectaddress=172.28.51.232


- wsl์—์„œ ์™ธ๋ถ€๋กœ ์—ด๋ฆฐ ํฌํŠธ ํ™•์ธ

netsh interface portproxy show v4tov4


- ๋งŒ์•ฝ ์œ„์—์„œ ์˜คํ”ˆํ•œ ํฌํŠธ๋ฅผ ๋‹ค์‹œ ๋‹ซ๊ณ  ์‹ถ๋‹ค๋ฉด

netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=8001

 

์ด๋ฏธ์ง€๋ฅผ ๋ฝ‘๋‹ค๋ณด๋ฉด ์ด๋ ‡๊ฒŒ ๋ณด๋ผ์ƒ‰ ์ ์ด ์ƒ๊ธธ๋•Œ๊ฐ€ ์žˆ๋‹ค

์ด๋•Œ ์˜คํ†  ์ธ์ฝ”๋” vae ํŒŒ์ผ๋กœ ํ›„๋ณด์ •์ด ํ•„์š”ํ•˜๋‹จ๋‹ค.

Settings ํƒญ์„ ํƒ > ์™ผ์ชฝ์˜ Stable Diffusion > SE VAE ์„ ํƒ์ฐฝ์—์„œ ์„ ํƒ

๋งŒ์•ฝ ํŒŒ์ผ์ด ์—†๋‹ค๋ฉด https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors <- ํด๋ฆญํ•˜๋ฉด ์ €์žฅ. 

์ €์žฅํ•œ ํŒŒ์ผ์„ stable-diffusion-webui\models\VAE ํด๋”์•ˆ์— ๋„ฃ๊ณ  ์ƒ๋‹จ์˜ Apply settings ๋ฒ„ํŠผ ํด๋ฆญ

ํ›„๋ณด์ •์„ ์œ„ํ•œ vae ์ข…๋ฅ˜๋„ ์—ฌ๋Ÿฌ๊ฐ€์ง€๊ฐ€ ์žˆ๋Š” ๊ฒƒ ๊ฐ™๋‹ค. 

๋‚˜์ค‘์— ํ•„์š”ํ•ด์ง€๋ฉด ๊ทธ๋•Œ๋‚˜ ์•Œ์•„๋ณด์ž

+ Recent posts