์ฝ๋ฉ์ผ๋ก ์ฒ๋ฆฌํ๋๋ถ๋ถ์ ์ดํดํ์ผ๋ ์ด์ ์น์ผ๋ก ์ฒ๋ฆฌํ๋ ๋ถ๋ถ์ ์ดํดํด๋ณด์.
stable-diffusion-webui ๋ผ๋ ์คํ์์ค ํ๋ก์ ํธ๋ฅผ ์ฌ์ฉํ๋ฉด ๋๋ค.
https://github.com/AUTOMATIC1111/stable-diffusion-webui/tree/master
Dockerfile ์์ฑ
FROM pytorch/pytorch:2.1.2-cuda12.1-cudnn8-runtime
RUN apt update
RUN apt install -y libgl1 wget git curl
RUN DEBIAN_FRONTEND=noninteractive TZ="America/Los_Angeles" apt install -y libglib2.0-0
WORKDIR /app
RUN git clone --depth 1 --branch v1.7.0 https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
RUN pip install -r stable-diffusion-webui/requirements.txt
# # root ์ฌ์ฉ ๊ฐ๋ฅํ๊ฒ
RUN sed -i 's/can_run_as_root=0/can_run_as_root=1/g' stable-diffusion-webui/webui.sh
EXPOSE 7860
WORKDIR /app/stable-diffusion-webui
ENTRYPOINT [ "python","launch.py","--listen"]
docker-compose.yaml ์์ฑ
version: '3.8'
services:
sd-webui:
build:
context: .
dockerfile: Dockerfile
container_name: sd-webui
restart: unless-stopped
ports:
- 7860:7860
volumes:
- ./models:/app/stable-diffusion-webui/models
- ./repositories:/app/stable-diffusion-webui/repositories
- ./outputs:/app/stable-diffusion-webui/outputs
- ./embeddings:/app/stable-diffusion-webui/embeddings
deploy:
resources:
reservations:
devices:
- driver: 'nvidia'
capabilities: [gpu]
count: all
์คํ
ํ์ธ
curl http://localhost:7860
![Alt text](images/2. SD-webui/image.png)
option ์ค๋ช
์ ํฌ๋ธ์ ๋ด์ฉ์ด ๋ง์ผ๋ฏ๋ก ํ์ธํด๋ณด๋ฉด๋ ๊ฑฐ๊ฐ๋ค. ๊ธฐ๋ณธ์ ์ธ๋ถ๋ถ์ ๋ค์๊ณผ ๊ฐ๋ค.
prompt : ์ํ๋ ์ด๋ฏธ์ง๋ฅผ ๋ํ๋ด๋ ๋จ์ด
negative prompt : ํฌํจ๋์ง ์๊ธฐ๋ฅผ ๋ฐ๋ผ๋ ๋จ์ด
sampling step : ๊ธฐ๋ณธ 20 ๋ฎ์ผ๋ฉด ๋ญ๊ฐ์ง ๋์ผ๋ฉด ๊นจ๋ํด์ง
sampleing method : ์กฐ๊ธ์ฉ ๋ค๋ฆ
width/height : ๊ฐ๋ก / ์ธ๋ก 512๊ฐ ๊ฐ์ฅ ์๋์จ๋ค.
restore faces : ์ผ๊ตด์ด ์ ๋ชป๋์ค๋๊ฑธ ๋ณด์ ํด์ค๋ค.
tiling : tiling์ด๋ฏธ์ง๋ฅผ ๋ง๋ค๋ ์์ฐ์ค๋ฝ๊ฒ ๋์ค๊ฒ ํ๋ค.
Highres : ์ด์ํ ์์๋ค์ ๋ณด์ ๋จธ๋ฆฌ๊ฐ ๋๊ฐ ๋ฑ๋ฑ
batch count/ size => ๊ณฑํ๋งํผ ๊ทธ๋ฆผ์ด ๋์จ๋ค.
cfg scale : ์ผ๋ง๋ ํ๋กฌํํธ๋ฅผ ๋ฐ๋ผ๊ฐ๋์ง ๋ฎ์ผ๋ฉด ํ๋กฌํํธ๋ ์๊ด์์ด ๋์ผ๋ฉด ํ๋กฌํ๊ฐ ๊ทธ๋๋ก
seed: ๊ธฐ์กด ์์ฑํ ์ด๋ฏธ์ง์ seed๊ฐ์ ๋ฃ์ผ๋ฉด ๊ธฐ์กด ์ด๋ฏธ์ง์คํ์ผ๊ณผ ๋น์ทํ๊ฒ ์์ฑ๋๋ค.
script :
prompt๋ฅผ ๋น๊ตํด์ ํ์ ํํ๋ก ๋ณด์ฌ์ค๋ค.
ํ๋กฌํํธ ํ์ผ์ ์
๋ก๋ ๋๋ค.
x/y plot x์ถ๊ณผ y์ถ์ ๋ค๋ฅธ ๊ฐ์ ๋ฃ์ด์ ํ๋ฉด์์ ๋น๊ตํ ์ ์๊ฒ table๋ก ๋์จ๋ค.
![Alt text](images/2. SD-webui/image-1.png)
๋๋คํ ํ๊ฐ์ ์ด๋ฆ์ ๋ฃ์ด์ค
๊ธฐ์กด ๊ทธ๋ฆผ์ ํ๋กฌํํธ๋ฅผ ๊ฐ์ ธ์์ ๋ณด์ฌ์ค
ํ๋กฌํํธ๋ฅผ ์ ์ฅํ ์ ์์ ๋ฐ๋ก ์์ ๋ก๋ฉํ ์ ์์
์ถ๊ฐ ์ฌ์ฉ๋ฒ
checkpoint์ lora, vae๋ฅผ ์ฌ์ฉํ๋ฉด ๋ ์ข์ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ ์ ์๋ค.
https://civitai.com ์ฌ๊ธฐ์์ ๋ชจ๋ธ์ ๋ค์ด๋ฐ์์ ์๋ค.
check point ์ฌ์ฉํ๊ธฐ
์ฌ์ดํธ์์ check point model์ ๋ฐ์์ stable-diffusion-webui/models/Stable-diffusion ํด๋์ ๋ฃ์ด์ค๋ค. ui์์ refresh๋ฅผ ๋๋ฅด๋ฉด ํ์ผ๋ณด์ธ๋ค ์ฌ์ฉํ๋ฉด๋๋ค.
lora ์ฌ์ฉํ๊ธฐ
์ฌ์ดํธ์์ lora๋ฅผ ๋ฐ์์ stable-diffusion-webui/models/Loraํด๋์ ๋ฃ์ด์ค๋ค. ui์์ refresh๋ฅผ ๋๋ฅด๋ฉด ํ์ผ๋ณด์ธ๋ค ์ฌ์ฉํ๋ฉด๋๋ค.
vae ์ฌ์ฉํ๊ธฐ
์ฌ์ดํธ์์ vae๋ฅผ ๋ฐ์์ stable-diffusion-webui/models/VAEํด๋์ ๋ฃ์ด์ค๋ค.
ui์์ refresh๋ฅผ ๋๋ฅด๋ฉด ํ์ผ๋ณด์ธ๋ค ์ฌ์ฉํ๋ฉด๋๋ค.
launch.py ์ต์
usage: launch.py [-h]
[--update-all-extensions]
[--skip-python-version-check]
[--skip-torch-cuda-test]
[--reinstall-xformers]
[--reinstall-torch]
[--update-check]
[--test-server]
[--log-startup]
[--skip-prepare-environment]
[--skip-install]
[--dump-sysinfo]
[--loglevel LOGLEVEL]
[--do-not-download-clip]
[--data-dir DATA_DIR]
[--config CONFIG]
[--ckpt CKPT]
[--ckpt-dir CKPT_DIR]
[--vae-dir VAE_DIR]
[--gfpgan-dir GFPGAN_DIR]
[--gfpgan-model GFPGAN_MODEL]
[--no-half]
[--no-half-vae]
[--no-progressbar-hiding]
[--max-batch-count MAX_BATCH_COUNT]
[--embeddings-dir EMBEDDINGS_DIR]
[--textual-inversion-templates-dir TEXTUAL_INVERSION_TEMPLATES_DIR]
[--hypernetwork-dir HYPERNETWORK_DIR]
[--localizations-dir LOCALIZATIONS_DIR]
[--allow-code]
[--medvram]
[--medvram-sdxl]
[--lowvram]
[--lowram]
[--always-batch-cond-uncond]
[--unload-gfpgan]
[--precision {full,autocast}]
[--upcast-sampling]
[--share]
[--ngrok NGROK]
[--ngrok-region NGROK_REGION]
[--ngrok-options NGROK_OPTIONS]
[--enable-insecure-extension-access]
[--codeformer-models-path CODEFORMER_MODELS_PATH]
[--gfpgan-models-path GFPGAN_MODELS_PATH]
[--esrgan-models-path ESRGAN_MODELS_PATH]
[--bsrgan-models-path BSRGAN_MODELS_PATH]
[--realesrgan-models-path REALESRGAN_MODELS_PATH]
[--clip-models-path CLIP_MODELS_PATH]
[--xformers]
[--force-enable-xformers]
[--xformers-flash-attention]
[--deepdanbooru]
[--opt-split-attention]
[--opt-sub-quad-attention]
[--sub-quad-q-chunk-size SUB_QUAD_Q_CHUNK_SIZE]
[--sub-quad-kv-chunk-size SUB_QUAD_KV_CHUNK_SIZE]
[--sub-quad-chunk-threshold SUB_QUAD_CHUNK_THRESHOLD]
[--opt-split-attention-invokeai]
[--opt-split-attention-v1]
[--opt-sdp-attention]
[--opt-sdp-no-mem-attention]
[--disable-opt-split-attention]
[--disable-nan-check]
[--use-cpu USE_CPU [USE_CPU ...]]
[--use-ipex]
[--disable-model-loading-ram-optimization]
[--listen]
[--port PORT]
[--show-negative-prompt]
[--ui-config-file UI_CONFIG_FILE]
[--hide-ui-dir-config]
[--freeze-settings]
[--ui-settings-file UI_SETTINGS_FILE]
[--gradio-debug]
[--gradio-auth GRADIO_AUTH]
[--gradio-auth-path GRADIO_AUTH_PATH]
[--gradio-img2img-tool GRADIO_IMG2IMG_TOOL]
[--gradio-inpaint-tool GRADIO_INPAINT_TOOL]
[--gradio-allowed-path GRADIO_ALLOWED_PATH]
[--opt-channelslast]
[--styles-file STYLES_FILE]
[--autolaunch]
[--theme THEME]
[--use-textbox-seed]
[--disable-console-progressbars]
[--enable-console-prompts]
[--vae-path VAE_PATH]
[--disable-safe-unpickle]
[--api]
[--api-auth API_AUTH]
[--api-log]
[--nowebui]
[--ui-debug-mode]
[--device-id DEVICE_ID]
[--administrator]
[--cors-allow-origins CORS_ALLOW_ORIGINS]
[--cors-allow-origins-regex CORS_ALLOW_ORIGINS_REGEX]
[--tls-keyfile TLS_KEYFILE]
[--tls-certfile TLS_CERTFILE]
[--disable-tls-verify]
[--server-name SERVER_NAME]
[--gradio-queue]
[--no-gradio-queue]
[--skip-version-check]
[--no-hashing]
[--no-download-sd-model]
[--subpath SUBPATH]
[--add-stop-route]
[--api-server-stop]
[--timeout-keep-alive TIMEOUT_KEEP_ALIVE]
[--disable-all-extensions]
[--disable-extra-extensions]
[--skip-load-model-at-start]
[--ldsr-models-path LDSR_MODELS_PATH]
[--lora-dir LORA_DIR]
[--lyco-dir-backcompat LYCO_DIR_BACKCOMPAT]
[--scunet-models-path SCUNET_MODELS_PATH]
[--swinir-models-path SWINIR_MODELS_PATH]
Last updated