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๋ณด๋‹ค ์†๋„๊ฐ€ ์›”๋“ฑํžˆ ๋น ๋ฅด๋‹ค. ๊ณ„์† ๋งŒ๋“ค๋ฉฐ ์‹คํ—˜ํ•˜๋ฉด ๋œ๋‹ค.

+ Recent posts